8000 Add option to restart menu cycle when pressing the same shortcut again by Schneegans · Pull Request #1008 · kando-menu/kando · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add option to restart menu cycle when pressing the same shortcut again #1008

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
},
"general-settings-dialog": {
"none": "None",
"auto-language": "Use system language",
"title": "General Settings",
"message": "All settings of Kando are stored in a JSON file which you can also edit, share, or backup. Click [here]({{link}}) to open the directory where the config.json file is stored.",
"app-settings": "Application Settings",
"localization-label": "Language",
"localization-info": "Restart Kando to apply the new language.",
"auto-language": "Use system language",
"check-for-new-versions": "Check for new versions",
"check-for-new-versions-info": "If enabled, Kando will show a notification when a new version is available.",
"invisible-settings-button": "Invisible settings button",
Expand Down Expand Up @@ -80,7 +80,8 @@
"press-again-behavior": "Press-shortcut-again behavior",
"press-again-behavior-info": "This determines what happens when the shortcut is pressed again while a menu is shown. If multiple menus are assigned to the same shortcut, you can use this to cycle through all matching menus. Make sure to only hold down a modifier key if you want to use Turbo Mode together with an option other than 'Do nothing'.",
"do-nothing": "Do nothing",
"cycle-menus": "Cycle through matching menus",
"cycle-from-first": "Show next menu (begin at first)",
"cycle-from-recent": "Show next menu (continue from last)",
"close-menu": "Close menu",
"menu-sounds": "Menu Sounds",
"learn-how-to-add-sound-themes": "Learn how to add new sound themes to Kando [here]({{link}})!",
Expand Down
2 changes: 1 addition & 1 deletion src/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ export interface IGeneralSettings {
gamepadCloseButton: number;

/** Determines the behavior of pressing the trigger shortcut once the menu is open. */
sameShortcutBehavior: 'cycle' | 'close' | 'nothing';
sameShortcutBehavior: 'cycle-from-first' | 'cycle-from-recent' | 'close' | 'nothing';

/**
* If enabled, pressing 'cmd + ,' on macOS or 'ctrl + ,' on Linux or Windows will open
Expand Down
12 changes: 10 additions & 2 deletions src/main/menu-window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,17 @@ export class MenuWindow extends BrowserWindow {

// If the 'sameShortcutBehavior' is set to 'cycle', we will show the next menu which
// matches the current request.
if (sameShortcutBehavior === 'cycle') {
if (
sameShortcutBehavior === 'cycle-from-first' ||
sameShortcutBehavior === 'cycle-from-recent'
) {
this.menuIndex += 1;
}
}
} else if (sameShortcutBehavior === 'cycle-from-first') {
// If the menu is not visible and the 'sameShortcutBehavior' is set to 'cycle-from-first',
// we reset the menu index to 0. This way, the first menu will be shown again.
this.menuIndex = 0;
}

// Select correct menu before showing it to user.
Expand Down Expand Up @@ -485,7 +492,8 @@ export class MenuWindow extends BrowserWindow {

// If the sameShortcutBehavior is set to 'cycle', we select the menu at the current
// index. If the index is out of bounds, we wrap around to the first menu.
if (this.kando.getGeneralSettings().get('sameShortcutBehavior') === 'cycle') {
const behavior = this.kando.getGeneralSettings().get('sameShortcutBehavior');
if (behavior === 'cycle-from-first' || behavior === 'cycle-from-recent') {
return bestMenus[this.menuIndex % bestMenus.length];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,12 @@ export default function GeneralSettingsDialog() {
label: i18next.t('settings.general-settings-dialog.do-nothing'),
},
{
value: 'cycle',
label: i18next.t('settings.general-settings-dialog.cycle-menus'),
value: 'cycle-from-first',
label: i18next.t('settings.general-settings-dialog.cycle-from-first'),
},
{
value: 'cycle-from-recent',
label: i18next.t('settings.general-settings-dialog.cycle-from-recent'),
},
{
value: 'close',
Expand Down
0