diff --git a/orx-panel/src/main/kotlin/org/openrndr/panel/elements/Slider.kt b/orx-panel/src/main/kotlin/org/openrndr/panel/elements/Slider.kt index 95d67e20..fad971f5 100644 --- a/orx-panel/src/main/kotlin/org/openrndr/panel/elements/Slider.kt +++ b/orx-panel/src/main/kotlin/org/openrndr/panel/elements/Slider.kt @@ -254,3 +254,26 @@ fun Slider.bind(property: KMutableProperty0) { } } } + +@JvmName("bindInt") +fun Slider.bind(property: KMutableProperty0) { + var currentValue: Int? = null + + events.valueChanged.listen { + currentValue = it.newValue.toInt() + property.set(it.newValue.toInt()) + } + if (root() as? Body == null) { + throw RuntimeException("no body") + } + (root() as? Body)?.controlManager?.program?.launch { + while (true) { + if (property.get()!= currentValue) { + val lcur = property.get() + currentValue = lcur + value = lcur.toDouble() + } + yield() + } + } +}