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

时间:2018-08-30 13:28:59

标签: javafx kotlin tornadofx

我需要通过右键单击更改tableview中的单元格颜色。我的代码:

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

第二种形式:

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

我知道我需要制作单元格格式侦听器,但是我尝试了不同的方法,但没有结果。谁能给我小费?

1 个答案:

答案 0 :(得分:0)

这听起来像是您标记了以后的操作的选择。您是否考虑过将CSS样式应用于所选项目的多选列表?

如果需要并行选择机制,也可以使用复选框来标记记录。