From 29da1c7339baa985d214a808ea5f4bb3ef743422 Mon Sep 17 00:00:00 2001 From: Vito Tardia Date: Wed, 29 Jun 2016 11:07:11 +0200 Subject: [PATCH] Better menu implementation --- app/lib/menu.js | 54 +++++-------------------------------------------- 1 file changed, 5 insertions(+), 49 deletions(-) diff --git a/app/lib/menu.js b/app/lib/menu.js index 75fa153..acd4f7c 100644 --- a/app/lib/menu.js +++ b/app/lib/menu.js @@ -9,36 +9,24 @@ var menuTemplate = [ label: 'Edit', submenu: [ { - label: 'Undo', - accelerator: 'CmdOrCtrl+Z', role: 'undo' }, { - label: 'Redo', - accelerator: 'Shift+CmdOrCtrl+Z', role: 'redo' }, { type: 'separator' }, { - label: 'Cut', - accelerator: 'CmdOrCtrl+X', role: 'cut' }, { - label: 'Copy', - accelerator: 'CmdOrCtrl+C', role: 'copy' }, { - label: 'Paste', - accelerator: 'CmdOrCtrl+V', role: 'paste' }, { - label: 'Select All', - accelerator: 'CmdOrCtrl+A', role: 'selectall' } ] @@ -65,19 +53,7 @@ var menuTemplate = [ } }, { - label: 'Toggle Full Screen', - accelerator: (function () { - if (process.platform === 'darwin') { - return 'Ctrl+Command+F' - } else { - return 'F11' - } - })(), - click: function (item, focusedWindow) { - if (focusedWindow) { - focusedWindow.setFullScreen(!focusedWindow.isFullScreen()) - } - } + role: 'togglefullscreen' } ] }, @@ -86,13 +62,9 @@ var menuTemplate = [ role: 'window', submenu: [ { - label: 'Minimize', - accelerator: 'CmdOrCtrl+M', role: 'minimize' }, { - label: 'Close', - accelerator: 'CmdOrCtrl+W', role: 'close' } ] @@ -116,16 +88,10 @@ if (isDev) { menuTemplate[1].submenu.push( { label: 'Toggle Developer Tools', - accelerator: (function () { - if (process.platform === 'darwin') { - return 'Alt+Command+I' - } else { - return 'Ctrl+Shift+I' - } - })(), + accelerator: process.platform === 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I', click: function (item, focusedWindow) { if (focusedWindow) { - focusedWindow.toggleDevTools() + focusedWindow.webContents.toggleDevTools() } } } @@ -133,19 +99,17 @@ if (isDev) { } if (process.platform === 'darwin') { - var name = require('electron').app.getName() + var name = app.getName() menuTemplate.unshift({ label: name, submenu: [ { - label: 'About ' + name, role: 'about' }, { type: 'separator' }, { - label: 'Services', role: 'services', submenu: [] }, @@ -153,26 +117,19 @@ if (process.platform === 'darwin') { type: 'separator' }, { - label: 'Hide ' + name, - accelerator: 'Command+H', role: 'hide' }, { - label: 'Hide Others', - accelerator: 'Command+Alt+H', role: 'hideothers' }, { - label: 'Show All', role: 'unhide' }, { type: 'separator' }, { - label: 'Quit', - accelerator: 'Command+Q', - click: function () { app.quit() } + role: 'quit' } ] }) @@ -182,7 +139,6 @@ if (process.platform === 'darwin') { type: 'separator' }, { - label: 'Bring All to Front', role: 'front' } )