Fix field/area left/right press with selected text

Fix bug in HTextField & HTextArea: when all text was selected, pressing
left or right arrow keys to go to the beginning or end and deselect
didn't respond.
This commit is contained in:
miruka 2020-07-07 10:03:35 -04:00
parent 24e657d193
commit 2674702a59
2 changed files with 6 additions and 4 deletions

View File

@ -95,8 +95,9 @@ TextArea {
// Prevent leaking arrow presses to parent elements when the carret is at // Prevent leaking arrow presses to parent elements when the carret is at
// the beginning or end of the text // the beginning or end of the text
Keys.onLeftPressed: event.accepted = cursorPosition === 0 Keys.onLeftPressed: event.accepted = cursorPosition === 0 && ! selectedText
Keys.onRightPressed: event.accepted = cursorPosition === length Keys.onRightPressed:
event.accepted = cursorPosition === length && ! selectedText
KeyNavigation.priority: KeyNavigation.BeforeItem KeyNavigation.priority: KeyNavigation.BeforeItem
KeyNavigation.tab: focusItemOnTab KeyNavigation.tab: focusItemOnTab

View File

@ -68,8 +68,9 @@ TextField {
// Prevent leaking arrow presses to parent elements when the carret is at // Prevent leaking arrow presses to parent elements when the carret is at
// the beginning or end of the text // the beginning or end of the text
Keys.onLeftPressed: event.accepted = cursorPosition === 0 Keys.onLeftPressed: event.accepted = cursorPosition === 0 && ! selectedText
Keys.onRightPressed: event.accepted = cursorPosition === length Keys.onRightPressed:
event.accepted = cursorPosition === length && ! selectedText
property string saveName: "" property string saveName: ""