package test.view import javafx.scene.input.Mouse...
# tornadofx
r
package test.view import javafx.scene.input.MouseEvent import tornadofx.* class data { var lastName by property <String>() fun lastNameProperty() = getProperty(data::lastName) var firstName by property<String>() fun firstNameProperty() = getProperty(data::firstName) override fun equals(other: Any?): Boolean { if(other is data){ if (lastName==other.lastName && firstName==other.firstName) return true } return false } override fun hashCode(): Int { return super.hashCode() } } class dataModel : ItemViewModel<data>() { val lastName = bind { item?.lastNameProperty() } val firstName = bind { item?.firstNameProperty() } } class MainView : View("Hello TornadoFX Application") { val list = mutableListOf<data>().observable() override val root = tableview<data>(list) { column("first name", data::firstName){isEditable=true} column("last name", data::lastName){isEditable=true} enableCellEditing() addEventFilter(MouseEvent.MOUSE_CLICKED) { event -> if (event.clickCount == 2 && event.target.isInsideTableRow() && selectionModel.isEmpty) { val transaction = data() items.add(transaction) edit(items.indexOf(transaction), columns.first()) } } } }