diff --git a/Modules/Launcher/Launcher.qml b/Modules/Launcher/Launcher.qml index 8aa60188..f8ee5db1 100644 --- a/Modules/Launcher/Launcher.qml +++ b/Modules/Launcher/Launcher.qml @@ -207,17 +207,15 @@ NPanel { // --------------------- // Navigation - function selectNext() { + function selectNextWrapped() { if (results.length > 0) { - // Clamp the index to not exceed the last item - selectedIndex = Math.min(selectedIndex + 1, results.length - 1) + selectedIndex = (selectedIndex + 1) % results.length } } - function selectPrevious() { + function selectPreviousWrapped() { if (results.length > 0) { - // Clamp the index to not go below the first item (0) - selectedIndex = Math.max(selectedIndex - 1, 0) + selectedIndex = (((selectedIndex - 1) % results.length) + results.length) % results.length } } @@ -257,13 +255,25 @@ NPanel { Shortcut { sequence: "Ctrl+K" - onActivated: ui.selectPrevious() + onActivated: ui.selectPreviousWrapped() enabled: root.opened && searchInput.inputItem && searchInput.inputItem.activeFocus } Shortcut { sequence: "Ctrl+J" - onActivated: ui.selectNext() + onActivated: ui.selectNextWrapped() + enabled: root.opened && searchInput.inputItem && searchInput.inputItem.activeFocus + } + + Shortcut { + sequence: "Tab" + onActivated: ui.selectNextWrapped() + enabled: root.opened && searchInput.inputItem && searchInput.inputItem.activeFocus + } + + Shortcut { + sequence: "Shift+Tab" + onActivated: ui.selectPreviousWrapped() enabled: root.opened && searchInput.inputItem && searchInput.inputItem.activeFocus } @@ -327,10 +337,10 @@ NPanel { } }) searchInput.inputItem.Keys.onDownPressed.connect(function (event) { - ui.selectNext() + ui.selectNextWrapped() }) searchInput.inputItem.Keys.onUpPressed.connect(function (event) { - ui.selectPrevious() + ui.selectPreviousWrapped() }) searchInput.inputItem.Keys.onReturnPressed.connect(function (event) { ui.activate() diff --git a/Modules/SessionMenu/SessionMenu.qml b/Modules/SessionMenu/SessionMenu.qml index 7bdbf22c..83afaf5f 100644 --- a/Modules/SessionMenu/SessionMenu.qml +++ b/Modules/SessionMenu/SessionMenu.qml @@ -119,15 +119,15 @@ NPanel { } // Navigation functions - function selectNext() { + function selectNextWrapped() { if (powerOptions.length > 0) { - selectedIndex = Math.min(selectedIndex + 1, powerOptions.length - 1) + selectedIndex = (selectedIndex + 1) % powerOptions.length } } - function selectPrevious() { + function selectPreviousWrapped() { if (powerOptions.length > 0) { - selectedIndex = Math.max(selectedIndex - 1, 0) + selectedIndex = (((selectedIndex - 1) % powerOptions.length) + powerOptions.length) % powerOptions.length } } @@ -170,25 +170,37 @@ NPanel { // Keyboard shortcuts Shortcut { sequence: "Ctrl+K" - onActivated: ui.selectPrevious() + onActivated: ui.selectPreviousWrapped() enabled: root.opened } Shortcut { sequence: "Ctrl+J" - onActivated: ui.selectNext() + onActivated: ui.selectNextWrapped() enabled: root.opened } Shortcut { sequence: "Up" - onActivated: ui.selectPrevious() + onActivated: ui.selectPreviousWrapped() enabled: root.opened } Shortcut { sequence: "Down" - onActivated: ui.selectNext() + onActivated: ui.selectNextWrapped() + enabled: root.opened + } + + Shortcut { + sequence: "Shift+Tab" + onActivated: ui.selectPreviousWrapped() + enabled: root.opened + } + + Shortcut { + sequence: "Tab" + onActivated: ui.selectNextWrapped() enabled: root.opened } @@ -231,14 +243,6 @@ NPanel { } // Navigation functions - function selectNext() { - root.selectNext() - } - - function selectPrevious() { - root.selectPrevious() - } - function selectFirst() { root.selectFirst() } @@ -247,6 +251,14 @@ NPanel { root.selectLast() } + function selectNextWrapped() { + root.selectNextWrapped() + } + + function selectPreviousWrapped() { + root.selectPreviousWrapped() + } + function activate() { root.activate() }