diff --git a/pom.xml b/pom.xml index fe52ed1..cedccb7 100755 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ 4.0.0 com.github.hanseter json-properties-fx - 1.0.9 + 1.0.10 bundle JSON Properties Editor Fx diff --git a/src/main/kotlin/com/github/hanseter/json/editor/controls/MultiLineStringControl.kt b/src/main/kotlin/com/github/hanseter/json/editor/controls/MultiLineStringControl.kt index 6af63c3..e34412b 100755 --- a/src/main/kotlin/com/github/hanseter/json/editor/controls/MultiLineStringControl.kt +++ b/src/main/kotlin/com/github/hanseter/json/editor/controls/MultiLineStringControl.kt @@ -1,7 +1,9 @@ package com.github.hanseter.json.editor.controls import javafx.beans.property.Property +import javafx.scene.control.ScrollPane import javafx.scene.control.TextArea +import javafx.scene.control.skin.TextAreaSkin class MultiLineStringControl : ControlWithProperty { override val control: TextArea = TextArea().apply { @@ -9,10 +11,20 @@ class MultiLineStringControl : ControlWithProperty { prefHeightProperty().bind(maxHeightProperty()) minHeightProperty().bind(maxHeightProperty()) textProperty().addListener { _, _, text -> - maxHeight = if ('\n' in text) 70.0 - else 26.0 + if ('\n' in text) { + maxHeight = 70.0 + setHorizonzalScrollbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED) + } else { + maxHeight = 26.0 + setHorizonzalScrollbarPolicy(ScrollPane.ScrollBarPolicy.NEVER) + } } } + + private fun TextArea.setHorizonzalScrollbarPolicy(policy: ScrollPane.ScrollBarPolicy) { + ((skin as TextAreaSkin).children.single() as ScrollPane).hbarPolicy = policy + } + override val property: Property get() = control.textProperty()