Fix cursor movement when mouse is pressed

This commit is contained in:
UnicornFreedom 2025-08-31 18:13:40 +02:00
parent 7316baa390
commit b17efa3aa2
No known key found for this signature in database
GPG Key ID: B4ED0DB6B940024F

View File

@ -139,12 +139,6 @@ class TextInput(val initialText: String = "") extends Widget with MouseHandler w
if (button != MouseEvent.Button.Right || !selection.active || clamped < selection.from || clamped > selection.to) { if (button != MouseEvent.Button.Right || !selection.active || clamped < selection.from || clamped > selection.to) {
setCursorAndSelectionPosition(clamped) setCursorAndSelectionPosition(clamped)
} }
// more special logic: keep `selection.from` updated even if there is no selection active
// in case there will be a follow-up drag event, which usually has some lag between initial click and following drag,
// and we would not want our mouse selection to lag
if (!selection.active) {
selection.from = clamped
}
} }
} }
@ -295,6 +289,8 @@ class TextInput(val initialText: String = "") extends Widget with MouseHandler w
cursor.position = position cursor.position = position
if (selection.active) { if (selection.active) {
selection.to = cursor.position selection.to = cursor.position
} else {
selection.from = cursor.position
} }
} }