Regarding your problem, you should keep in mind fe...
# tornadofx
m
Regarding your problem, you should keep in mind few things. JavaFX properties are made to support data binding. Kotlin properties can't do that. You can access JavaFx properties via Kotlin properties using Kotlin property delegation. For example, given the following definitions:
Copy code
operator fun <T> ObservableValue<T>.getValue(thisRef: Any, property: KProperty<*>) = value
operator fun <T> Property<T>.setValue(thisRef: Any, property: KProperty<*>, value: T?) = setValue(value)
you can write:
Copy code
val xyzProperty = objectProperty<XYZ>()
val xyz by xyzProperty
Where
xyzProperty
is a JavaFX property (supporting databing, but with an ugly syntax), and
xyz
is a Kotlin property, with the customary property syntax but no databinding. You can't do more than that in Kotlin, so TornadoFX can't do more than that, either. So when you want to perform assignment or read the value, you can use
xyz
(and you can chain it, like in
xyz.abc.mno
) but when you want to bind you have to use
xyzProperty
, and the "select" operation from JavaFX, which is wrapped in the
select
extension methods by TornadoFX. I use property delegation to JavaFX properties, JavaFX property constructors and binding helpers like
select
in my code, too, even if I don't use TornadoFX anymore. It takes just a bunch of extension functions, mostly. You are confused by the fact that you can write
Copy code
someBuilder(<http://obj.xyz|obj.xyz>) {
}
when using TornadoFX. You are just passing the value of the property, in that case. You can use "." to traverse the object graph, but the resulting UI widget is not data-bound. You'll often find an overload of the same builder which takes a JavaFX property. You have to use that, traversing the object graph with
select
.