diff --git a/src/gui/Base/HTextArea.qml b/src/gui/Base/HTextArea.qml index dfa1057a..6b0c83a5 100644 --- a/src/gui/Base/HTextArea.qml +++ b/src/gui/Base/HTextArea.qml @@ -83,11 +83,17 @@ TextArea { onTextChanged: window.saveState(this) + // Prevent alt/super+any key from typing text Keys.onPressed: if ( event.modifiers & Qt.AltModifier || event.modifiers & Qt.MetaModifier ) event.accepted = true + // 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 + KeyNavigation.priority: KeyNavigation.BeforeItem KeyNavigation.tab: focusItemOnTab diff --git a/src/gui/Base/HTextField.qml b/src/gui/Base/HTextField.qml index 8f1859c1..b07a3c47 100644 --- a/src/gui/Base/HTextField.qml +++ b/src/gui/Base/HTextField.qml @@ -58,10 +58,16 @@ TextField { onActiveFocusChanged: text = activeFocus || changed ? text : Qt.binding(() => defaultText) + // Prevent alt/super+any key from typing text Keys.onPressed: if ( event.modifiers & Qt.AltModifier || event.modifiers & Qt.MetaModifier - ) event.accepted = true // XXX Still needed? + ) event.accepted = true + + // 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 property string saveName: ""