what's the TornadoFX way to add a child to a pane ...
# tornadofx
p
what's the TornadoFX way to add a child to a pane after it has been already constructed? lets say I have this DSL:
Copy code
vbox {
    button {
        action {
            // call a method that adds another button to vbox
        }
    }
}
I guess I could pass a reference to the vbox
this@vbox
to the method and then use
add(...)
but I guess there is a more idiomatic way?
c
You could assign it to a member variable
Copy code
lateinit var theVbox: VBox
vbox {
    theVbox = this
    button("Original") {
        action { performAdd() }
    }
}

fun performAdd() {
    theVbox.add(Button("another"))
}
That would cut down the arguments needed in the method signature, and would still work if the original button needed to be moved out of the same vbox as where the new children go
p
thanks