From d49a0ab6926e090a0800cb49ab2cd2edc7a8d2b3 Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Tue, 14 Sep 2021 17:04:38 +0200 Subject: [PATCH 1/2] Support enter/return and up/down keys in Global drawer for navigation Enter/return will do the same as clicking on the item, while up/down match backtab/tab. --- src/controls/GlobalDrawer.qml | 6 ++++++ src/controls/private/GlobalDrawerActionItem.qml | 10 +++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/controls/GlobalDrawer.qml b/src/controls/GlobalDrawer.qml index 7efa7e321..2e90e0e8e 100644 --- a/src/controls/GlobalDrawer.qml +++ b/src/controls/GlobalDrawer.qml @@ -472,6 +472,12 @@ OverlayDrawer { separatorVisible: false onClicked: stackView.pop() + + Keys.onEnterPressed: stackView.pop() + Keys.onReturnPressed: stackView.pop() + + Keys.onDownPressed: nextItemInFocusChain().focus = true + Keys.onUpPressed: nextItemInFocusChain(false).focus = true } Shortcut { sequence: backItem.MnemonicData.sequence diff --git a/src/controls/private/GlobalDrawerActionItem.qml b/src/controls/private/GlobalDrawerActionItem.qml index 5f3e17dfa..ee86a4374 100644 --- a/src/controls/private/GlobalDrawerActionItem.qml +++ b/src/controls/private/GlobalDrawerActionItem.qml @@ -143,7 +143,12 @@ AbstractListItem { } } } - onClicked: { + + onClicked: trigger() + Keys.onEnterPressed: trigger() + Keys.onReturnPressed: trigger() + + function trigger() { if (!supportsMouseEvents) { return; } @@ -167,4 +172,7 @@ AbstractListItem { } checked = Qt.binding(function() { return modelData.checked || (actionsMenu && actionsMenu.visible) }); } + + Keys.onDownPressed: nextItemInFocusChain().focus = true + Keys.onUpPressed: nextItemInFocusChain(false).focus = true } -- GitLab From d97773ed467ab0947e35dee2b696aabd7feeb947 Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Tue, 14 Sep 2021 17:05:49 +0200 Subject: [PATCH 2/2] Set activeFocusOnTab to false for ListSectionHeader While section headers may contain controls that need focus, they should rarely accept focus themselves. Therefore, it makes more sense to default them to not accepting focus. --- src/controls/ListSectionHeader.qml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/controls/ListSectionHeader.qml b/src/controls/ListSectionHeader.qml index 2fb4e660e..a2cfa39fb 100644 --- a/src/controls/ListSectionHeader.qml +++ b/src/controls/ListSectionHeader.qml @@ -56,6 +56,8 @@ Kirigami.AbstractListItem { sectionDelegate: true hoverEnabled: false + activeFocusOnTab: false + contentItem: RowLayout { id: rowLayout -- GitLab