Kotlin/TornadoFX - bind 2D array to grid of buttons

Viewed 150

I am making a program with a grid of buttons using TornadoFX and I want to bind a 2D grid of buttons to a corresponding 2D array of boolean values.

display is a 2D boolean array in Kotlin

val gridArray = FXCollections.observableArrayList(display)

This is the current code I have for the button grid

        gridpane {
            for (row_num in 0..15) {
                row {
                    for (col_num in 0..15) {
                        button("") {
                            style = "-fx-background-radius: 256;"
                            action {
                                state.GridPress(row_num, col_num)
                            }
                        }.setPrefSize(32.0, 32.0)
                    }
                }
            }
        }

I want to bind them so that any changes to the boolean array will immediately update the style of the buttons.

0 Answers
Related