mirror of
https://github.com/zoriya/noctalia-shell.git
synced 2026-06-05 11:40:00 +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
|
// Navigation
|
||||||
function selectNext() {
|
function selectNextWrapped() {
|
||||||
if (results.length > 0) {
|
if (results.length > 0) {
|
||||||
// Clamp the index to not exceed the last item
|
selectedIndex = (selectedIndex + 1) % results.length
|
||||||
selectedIndex = Math.min(selectedIndex + 1, results.length - 1)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectPrevious() {
|
function selectPreviousWrapped() {
|
||||||
if (results.length > 0) {
|
if (results.length > 0) {
|
||||||
// Clamp the index to not go below the first item (0)
|
selectedIndex = (((selectedIndex - 1) % results.length) + results.length) % results.length
|
||||||
selectedIndex = Math.max(selectedIndex - 1, 0)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -257,13 +255,25 @@ NPanel {
|
|||||||
|
|
||||||
Shortcut {
|
Shortcut {
|
||||||
sequence: "Ctrl+K"
|
sequence: "Ctrl+K"
|
||||||
onActivated: ui.selectPrevious()
|
onActivated: ui.selectPreviousWrapped()
|
||||||
enabled: root.opened && searchInput.inputItem && searchInput.inputItem.activeFocus
|
enabled: root.opened && searchInput.inputItem && searchInput.inputItem.activeFocus
|
||||||
}
|
}
|
||||||
|
|
||||||
Shortcut {
|
Shortcut {
|
||||||
sequence: "Ctrl+J"
|
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
|
enabled: root.opened && searchInput.inputItem && searchInput.inputItem.activeFocus
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,10 +337,10 @@ NPanel {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
searchInput.inputItem.Keys.onDownPressed.connect(function (event) {
|
searchInput.inputItem.Keys.onDownPressed.connect(function (event) {
|
||||||
ui.selectNext()
|
ui.selectNextWrapped()
|
||||||
})
|
})
|
||||||
searchInput.inputItem.Keys.onUpPressed.connect(function (event) {
|
searchInput.inputItem.Keys.onUpPressed.connect(function (event) {
|
||||||
ui.selectPrevious()
|
ui.selectPreviousWrapped()
|
||||||
})
|
})
|
||||||
searchInput.inputItem.Keys.onReturnPressed.connect(function (event) {
|
searchInput.inputItem.Keys.onReturnPressed.connect(function (event) {
|
||||||
ui.activate()
|
ui.activate()
|
||||||
|
|||||||
@@ -119,15 +119,15 @@ NPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Navigation functions
|
// Navigation functions
|
||||||
function selectNext() {
|
function selectNextWrapped() {
|
||||||
if (powerOptions.length > 0) {
|
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) {
|
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
|
// Keyboard shortcuts
|
||||||
Shortcut {
|
Shortcut {
|
||||||
sequence: "Ctrl+K"
|
sequence: "Ctrl+K"
|
||||||
onActivated: ui.selectPrevious()
|
onActivated: ui.selectPreviousWrapped()
|
||||||
enabled: root.opened
|
enabled: root.opened
|
||||||
}
|
}
|
||||||
|
|
||||||
Shortcut {
|
Shortcut {
|
||||||
sequence: "Ctrl+J"
|
sequence: "Ctrl+J"
|
||||||
onActivated: ui.selectNext()
|
onActivated: ui.selectNextWrapped()
|
||||||
enabled: root.opened
|
enabled: root.opened
|
||||||
}
|
}
|
||||||
|
|
||||||
Shortcut {
|
Shortcut {
|
||||||
sequence: "Up"
|
sequence: "Up"
|
||||||
onActivated: ui.selectPrevious()
|
onActivated: ui.selectPreviousWrapped()
|
||||||
enabled: root.opened
|
enabled: root.opened
|
||||||
}
|
}
|
||||||
|
|
||||||
Shortcut {
|
Shortcut {
|
||||||
sequence: "Down"
|
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
|
enabled: root.opened
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,14 +243,6 @@ NPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Navigation functions
|
// Navigation functions
|
||||||
function selectNext() {
|
|
||||||
root.selectNext()
|
|
||||||
}
|
|
||||||
|
|
||||||
function selectPrevious() {
|
|
||||||
root.selectPrevious()
|
|
||||||
}
|
|
||||||
|
|
||||||
function selectFirst() {
|
function selectFirst() {
|
||||||
root.selectFirst()
|
root.selectFirst()
|
||||||
}
|
}
|
||||||
@@ -247,6 +251,14 @@ NPanel {
|
|||||||
root.selectLast()
|
root.selectLast()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function selectNextWrapped() {
|
||||||
|
root.selectNextWrapped()
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectPreviousWrapped() {
|
||||||
|
root.selectPreviousWrapped()
|
||||||
|
}
|
||||||
|
|
||||||
function activate() {
|
function activate() {
|
||||||
root.activate()
|
root.activate()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user