Fix cursor positioning on TextInput text set

This commit is contained in:
UnicornFreedom 2025-08-22 15:20:01 +02:00
parent 4e9d7c96e2
commit 6f5f84e5fd
No known key found for this signature in database
GPG Key ID: B4ED0DB6B940024F

View File

@ -71,6 +71,7 @@ class TextInput(val initialText: String = "") extends Widget with MouseHandler w
def text_=(value: String): Unit = {
_text.chars = value.codePoints().toArray
selector.active = false
cursor.position = cursor.position max 0 min _text.chars.length
}
private def selectedText: String = new String(_text.chars, selector.start, selector.length)