简体   繁体   English

如何在双击Tornadofx上更改单元格颜色

[英]How to make cell color change on double click tornadofx

I need to make cells color in my tableview be changed by right mouse click. 我需要通过右键单击更改tableview单元格颜色。 My code: 我的代码:

cellFormat { _ ->
    graphicProperty().addListener { _ ->
        setOnMouseClicked {
            if (it.button == MouseButton.SECONDARY)
                style {
                    backgroundColor += c("darkred")
                }
        }
    }
}

second variant: 第二个变体:

cellFormat { _ ->
                style {
                setOnMouseClicked { button ->
                    if (button.button == MouseButton.SECONDARY) {
                        backgroundColor += c("darkred")
                    }
                }
            } }

I understand that I need to make cell format listener, however I tried different ways and have no result. 我知道我需要制作单元格格式侦听器,但是我尝试了不同的方法,但没有结果。 Can anyone give me a tip? 谁能给我小费?

This sounds like you are marking selections for a later operation. 听起来您正在标记选择以便以后进行操作。 Have you considered a multi-select list with a CSS style applied to selected items? 您是否考虑过将CSS样式应用于所选项目的多选列表?

A checkbox could also be used to mark off records if you have need for a parallel selection mechanism. 如果需要并行选择机制,也可以使用复选框标记记录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM