Improve keyboard navigation

Simply enabling activeFocusOnTab on a few key elements massively improves the
keyboard navigation. Additionally, making the text box forward tab events when
appropriate allows for focus to pass through it without getitng stuck.
This commit is contained in:
Jan Blackquill
2021-04-21 18:31:30 -04:00
committed by Carl Schwan
parent 08632b4178
commit d5d83ff7b8
3 changed files with 14 additions and 7 deletions

View File

@@ -159,14 +159,16 @@ ToolBar {
switchRoomUp(); switchRoomUp();
return; return;
} }
if (isCompleting) { if (!isCompleting) {
let decrementedIndex = completionMenu.currentIndex - 1 nextItemInFocusChain(false).forceActiveFocus(Qt.TabFocusReason)
// Wrap around to the last item return
if (decrementedIndex < 0) {
decrementedIndex = Math.max(completionMenu.count - 1, 0) // 0 if count == 0
}
completionMenu.currentIndex = decrementedIndex
} }
let decrementedIndex = completionMenu.currentIndex - 1
// Wrap around to the last item
if (decrementedIndex < 0) {
decrementedIndex = Math.max(completionMenu.count - 1, 0) // 0 if count == 0
}
completionMenu.currentIndex = decrementedIndex
} }
Keys.onTabPressed: { Keys.onTabPressed: {
@@ -175,6 +177,7 @@ ToolBar {
return; return;
} }
if (!isCompleting) { if (!isCompleting) {
nextItemInFocusChain().forceActiveFocus(Qt.TabFocusReason);
return; return;
} }

View File

@@ -48,6 +48,8 @@ Kirigami.ScrollablePage {
ListView { ListView {
id: listView id: listView
activeFocusOnTab: true
Kirigami.PlaceholderMessage { Kirigami.PlaceholderMessage {
anchors.centerIn: parent anchors.centerIn: parent
width: parent.width - (Kirigami.Units.largeSpacing * 4) width: parent.width - (Kirigami.Units.largeSpacing * 4)

View File

@@ -147,6 +147,7 @@ Kirigami.OverlayDrawer {
Kirigami.ListSectionHeader { Kirigami.ListSectionHeader {
label: i18n("Members") label: i18n("Members")
activeFocusOnTab: false
Label { Label {
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
text: room ? i18np("%1 Member", "%1 Members", room.totalMemberCount) : i18n("No Member Count") text: room ? i18np("%1 Member", "%1 Members", room.totalMemberCount) : i18n("No Member Count")
@@ -162,6 +163,7 @@ Kirigami.OverlayDrawer {
clip: true clip: true
headerPositioning: ListView.OverlayHeader headerPositioning: ListView.OverlayHeader
boundsBehavior: Flickable.DragOverBounds boundsBehavior: Flickable.DragOverBounds
activeFocusOnTab: true
header: Pane { header: Pane {
padding: Kirigami.Units.smallSpacing padding: Kirigami.Units.smallSpacing