From 5055ad0aec29abbf342d56902d6779f53380d5cd Mon Sep 17 00:00:00 2001 From: Aaron Raimist Date: Thu, 3 Jun 2021 22:56:02 -0500 Subject: [PATCH] Put Preferences menu item in correct location on macOS Signed-off-by: Aaron Raimist --- src/vectormenu.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/vectormenu.js b/src/vectormenu.js index a14aab0..f78635c 100644 --- a/src/vectormenu.js +++ b/src/vectormenu.js @@ -17,6 +17,8 @@ limitations under the License. const { app, shell, Menu } = require('electron'); const { _t } = require('./language-helper'); +const isMac = process.platform === 'darwin'; + function buildMenuTemplate() { // Menu template from http://electron.atom.io/docs/api/menu/, edited const template = [ @@ -78,11 +80,11 @@ function buildMenuTemplate() { label: _t('Zoom Out'), }, { type: 'separator' }, - { + // in macOS the Preferences menu item goes in the first menu + ...(!isMac ? [{ label: _t('Preferences'), - accelerator: 'Command+,', // Mac-only accelerator click() { global.mainWindow.webContents.send('preferences'); }, - }, + }] : []), { role: 'togglefullscreen', label: _t('Toggle Full Screen'), @@ -122,7 +124,7 @@ function buildMenuTemplate() { ]; // macOS has specific menu conventions... - if (process.platform === 'darwin') { + if (isMac) { template.unshift({ // first macOS menu is the name of the app role: 'appMenu', @@ -133,6 +135,12 @@ function buildMenuTemplate() { label: _t('About'), }, { type: 'separator' }, + { + label: _t('Preferences'), + accelerator: 'Command+,', // Mac-only accelerator + click() { global.mainWindow.webContents.send('preferences'); }, + }, + { type: 'separator' }, { role: 'services', label: _t('Services'),