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();
return;
}
if (isCompleting) {
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
if (!isCompleting) {
nextItemInFocusChain(false).forceActiveFocus(Qt.TabFocusReason)
return
}
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: {
@@ -175,6 +177,7 @@ ToolBar {
return;
}
if (!isCompleting) {
nextItemInFocusChain().forceActiveFocus(Qt.TabFocusReason);
return;
}

View File

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

View File

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