Launcher: replace select next/previous usage with wrapping version

This commit is contained in:
Damian D'Souza
2025-10-17 00:46:34 +02:00
parent ab59e94ee6
commit 68b3483162
+4 -18
View File
@@ -207,20 +207,6 @@ NPanel {
// ---------------------
// Navigation
function selectNext() {
if (results.length > 0) {
// Clamp the index to not exceed the last item
selectedIndex = Math.min(selectedIndex + 1, results.length - 1)
}
}
function selectPrevious() {
if (results.length > 0) {
// Clamp the index to not go below the first item (0)
selectedIndex = Math.max(selectedIndex - 1, 0)
}
}
function selectNextWrapped() {
if (results.length > 0) {
selectedIndex = (selectedIndex + 1) % results.length
@@ -269,13 +255,13 @@ 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
}
@@ -351,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()