[orx-toggle] Fix bind for Toggle
This commit is contained in:
@@ -106,14 +106,20 @@ fun Toggle.bind(property: KMutableProperty0<Boolean>) {
|
|||||||
currentValue = it.newValue
|
currentValue = it.newValue
|
||||||
property.set(it.newValue)
|
property.set(it.newValue)
|
||||||
}
|
}
|
||||||
|
if (root() as? Body == null) {
|
||||||
|
throw RuntimeException("no body")
|
||||||
|
}
|
||||||
|
fun update() {
|
||||||
|
if (property.get() != currentValue) {
|
||||||
|
val lcur = property.get()
|
||||||
|
currentValue = lcur
|
||||||
|
value = lcur
|
||||||
|
}
|
||||||
|
}
|
||||||
|
update()
|
||||||
(root() as Body).controlManager.program.launch {
|
(root() as Body).controlManager.program.launch {
|
||||||
while (!disposed) {
|
while (!disposed) {
|
||||||
val cval = property.get()
|
update()
|
||||||
if (cval != currentValue) {
|
|
||||||
currentValue = cval
|
|
||||||
value = cval
|
|
||||||
}
|
|
||||||
yield()
|
yield()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user