From 2674702a59598b4303a6ed7507faf4bf5befe748 Mon Sep 17 00:00:00 2001 From: miruka Date: Tue, 7 Jul 2020 10:03:35 -0400 Subject: [PATCH] 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. --- src/gui/Base/HTextArea.qml | 5 +++-- src/gui/Base/HTextField.qml | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gui/Base/HTextArea.qml b/src/gui/Base/HTextArea.qml index 1992d085..a01fd75c 100644 --- a/src/gui/Base/HTextArea.qml +++ b/src/gui/Base/HTextArea.qml @@ -95,8 +95,9 @@ TextArea { // Prevent leaking arrow presses to parent elements when the carret is at // the beginning or end of the text - Keys.onLeftPressed: event.accepted = cursorPosition === 0 - Keys.onRightPressed: event.accepted = cursorPosition === length + Keys.onLeftPressed: event.accepted = cursorPosition === 0 && ! selectedText + Keys.onRightPressed: + event.accepted = cursorPosition === length && ! selectedText KeyNavigation.priority: KeyNavigation.BeforeItem KeyNavigation.tab: focusItemOnTab diff --git a/src/gui/Base/HTextField.qml b/src/gui/Base/HTextField.qml index e26a7be3..fd7a735d 100644 --- a/src/gui/Base/HTextField.qml +++ b/src/gui/Base/HTextField.qml @@ -68,8 +68,9 @@ TextField { // Prevent leaking arrow presses to parent elements when the carret is at // the beginning or end of the text - Keys.onLeftPressed: event.accepted = cursorPosition === 0 - Keys.onRightPressed: event.accepted = cursorPosition === length + Keys.onLeftPressed: event.accepted = cursorPosition === 0 && ! selectedText + Keys.onRightPressed: + event.accepted = cursorPosition === length && ! selectedText property string saveName: ""