diff --git a/ui/react/src/main/kotlin/hep/dataforge/vision/react/valueChooser.kt b/ui/react/src/main/kotlin/hep/dataforge/vision/react/valueChooser.kt index 86af2e4c..6c043e19 100644 --- a/ui/react/src/main/kotlin/hep/dataforge/vision/react/valueChooser.kt +++ b/ui/react/src/main/kotlin/hep/dataforge/vision/react/valueChooser.kt @@ -30,7 +30,7 @@ public val StringValueChooser: FunctionalComponent = val keyDown: (Event) -> Unit = { event -> if (event.type == "keydown" && event.asDynamic().key == "Enter") { value = (event.target as HTMLInputElement).value - if(value!= props.item.string) { + if (value != props.item.string) { props.valueChanged?.invoke(value.asValue()) } } @@ -50,16 +50,14 @@ public val StringValueChooser: FunctionalComponent = @JsExport public val BooleanValueChooser: FunctionalComponent = functionalComponent("BooleanValueChooser") { props -> - var checkedValue by useState(props.item.boolean ?: false) val handleChange: (Event) -> Unit = { val newValue = (it.target as HTMLInputElement).checked - checkedValue = newValue props.valueChanged?.invoke(newValue.asValue()) } styledInput(type = InputType.checkBox) { attrs { - this.attributes["indeterminate"] = (checkedValue == null).toString() - checked = checkedValue + //this.attributes["indeterminate"] = (props.item == null).toString() + defaultChecked = props.item.boolean ?: false onChangeFunction = handleChange } } @@ -68,24 +66,24 @@ public val BooleanValueChooser: FunctionalComponent = @JsExport public val NumberValueChooser: FunctionalComponent = functionalComponent("NumberValueChooser") { props -> - var value by useState(props.item.string ?: "") + var innerValue by useState(props.item.string ?: "") val keyDown: (Event) -> Unit = { event -> if (event.type == "keydown" && event.asDynamic().key == "Enter") { - value = (event.target as HTMLInputElement).value - val number = value.toDoubleOrNull() + innerValue = (event.target as HTMLInputElement).value + val number = innerValue.toDoubleOrNull() if (number == null) { - console.error("The input value $value is not a number") + console.error("The input value $innerValue is not a number") } else { props.valueChanged?.invoke(number.asValue()) } } } val handleChange: (Event) -> Unit = { - value = (it.target as HTMLInputElement).value + innerValue = (it.target as HTMLInputElement).value } styledInput(type = InputType.number) { attrs { - this.value = value + value = innerValue onKeyDownFunction = keyDown onChangeFunction = handleChange props.descriptor?.attributes?.get("step").string?.let { diff --git a/visionforge-core/src/commonMain/kotlin/hep/dataforge/vision/VisionBase.kt b/visionforge-core/src/commonMain/kotlin/hep/dataforge/vision/VisionBase.kt index e04be28f..b3a2fafa 100644 --- a/visionforge-core/src/commonMain/kotlin/hep/dataforge/vision/VisionBase.kt +++ b/visionforge-core/src/commonMain/kotlin/hep/dataforge/vision/VisionBase.kt @@ -34,16 +34,16 @@ internal data class PropertyListener( @SerialName("vision") public open class VisionBase(internal var properties: Config? = null) : Vision { - init { - //used during deserialization only - properties?.onChange(this) { name, oldItem, newItem -> - if (oldItem != newItem) { - scope.launch { - notifyPropertyChanged(name) - } - } - } - } +// init { +// //used during deserialization only +// properties?.onChange(this) { name, oldItem, newItem -> +// if (oldItem != newItem) { +// scope.launch { +// notifyPropertyChanged(name) +// } +// } +// } +// } @Transient override var parent: VisionGroup? = null @@ -54,13 +54,13 @@ public open class VisionBase(internal var properties: Config? = null) : Vision { protected fun getOrCreateConfig(): Config { if (properties == null) { val newProperties = Config() - newProperties.onChange(this) { name, oldItem, newItem -> - if (oldItem != newItem) { - scope.launch { - notifyPropertyChanged(name) - } - } - } +// newProperties.onChange(this) { name, oldItem, newItem -> +// if (oldItem != newItem) { +// scope.launch { +// notifyPropertyChanged(name) +// } +// } +// } properties = newProperties } return properties!! diff --git a/visionforge-threejs/src/main/kotlin/hep/dataforge/vision/solid/three/MeshThreeFactory.kt b/visionforge-threejs/src/main/kotlin/hep/dataforge/vision/solid/three/MeshThreeFactory.kt index a9d405f2..f04e7a1a 100644 --- a/visionforge-threejs/src/main/kotlin/hep/dataforge/vision/solid/three/MeshThreeFactory.kt +++ b/visionforge-threejs/src/main/kotlin/hep/dataforge/vision/solid/three/MeshThreeFactory.kt @@ -42,7 +42,6 @@ public abstract class MeshThreeFactory( //add listener to object properties obj.onPropertyChange(three.updateScope) { name -> - println("Property $name of mesh ${mesh.name} updated") when { name.startsWith(Solid.GEOMETRY_KEY) -> { val oldGeometry = mesh.geometry as BufferGeometry diff --git a/visionforge-threejs/src/main/kotlin/hep/dataforge/vision/solid/three/ThreeReferenceFactory.kt b/visionforge-threejs/src/main/kotlin/hep/dataforge/vision/solid/three/ThreeReferenceFactory.kt index 34b1aebd..cbee5aa7 100644 --- a/visionforge-threejs/src/main/kotlin/hep/dataforge/vision/solid/three/ThreeReferenceFactory.kt +++ b/visionforge-threejs/src/main/kotlin/hep/dataforge/vision/solid/three/ThreeReferenceFactory.kt @@ -47,7 +47,6 @@ public object ThreeReferenceFactory : ThreeFactory { //TODO apply child properties obj.onPropertyChange(three.updateScope) { name-> - println("Property $name of reference ${object3D.name} updated") if (name.firstOrNull()?.body == REFERENCE_CHILD_PROPERTY_PREFIX) { val childName = name.firstOrNull()?.index?.toName() ?: error("Wrong syntax for reference child property: '$name'") val propertyName = name.cutFirst()