mirror of
https://github.com/zoriya/noctalia-shell.git
synced 2026-05-23 23:06:56 +00:00
Merge pull request #499 from damian-ds7/tab-navigation-session-menu-launcher
Tab navigation in session menu and launcher
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user