MrSpeedy
MrSpeedy

Reputation: 51

How to Update TornadoFX ComboBox - Kotlin

I'm making a simple application where you can add and delete Materials and printers. I'm using a TornadoFX UI with Kotlin and I have all the objects stored in a JSON file that's read in and converted to an observable list (printerData) that's displayed in the combobox. My issue is that when I add a new object the combo box is not updated until I restart the application.

var selectedPrinter = model.bind { SimpleObjectProperty<PrinterModel>() }
var selectedMaterial = model.bind { SimpleObjectProperty<MaterialModel>() }

val printers = PrinterJSONStore()
var printerData = printers.findAllObservable().observable()

val materials = MaterialJSONStore()
var materialData = materials.findAllObservable().observable()
    
override val root = form {
       setPrefSize(400.0, 600.0)
       fieldset(labelPosition = Orientation.VERTICAL) {

text("")
    combobox(selectedMaterial,materialData) {
        makeAutocompletable()
    }

text("")
    combobox(selectedPrinter, printerData)

}
}

Upvotes: 1

Views: 96

Answers (0)

Related Questions