Skip to content

Commit

Permalink
Merge pull request #778 from dyaskur/fix_shortcut_on_macos
Browse files Browse the repository at this point in the history
fix: shortcut not working on mac os
  • Loading branch information
Fabio286 authored Mar 14, 2024
2 parents de9dac3 + 0bb5ced commit 11f130d
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/main/libs/ShortcutRegister.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,21 @@ export class ShortcutRegister {
}

private setLocalShortcuts () {
const isMenuVisible = process.platform === 'darwin';
const submenu = [];
for (const shortcut of this.shortcuts) {
if (shortcut.os.includes(process.platform)) {
for (const key of shortcut.keys) {
try {
this._menu.append(new MenuItem({
label: '.',
visible: false,
submenu: [{
label: String(key),
accelerator: key,
visible: false,
click: () => {
this._mainWindow.webContents.send(shortcut.event);
if (isDevelopment) console.log('LOCAL EVENT:', shortcut);
}
}]
}));
submenu.push({
label: String(shortcut.event),
accelerator: key,
visible: isMenuVisible,
click: () => {
this._mainWindow.webContents.send(shortcut.event);
if (isDevelopment) console.log('LOCAL EVENT:', shortcut);
}
});
}
catch (error) {
if (isDevelopment) console.log(error);
Expand All @@ -96,6 +94,11 @@ export class ShortcutRegister {
}
}
}
this._menu.append(new MenuItem({
label: 'Shortcut',
visible: isMenuVisible,
submenu
}));
}

private setGlobalShortcuts () {
Expand Down

0 comments on commit 11f130d

Please sign in to comment.