diff --git a/src/main/MacOSMenu.js b/src/main/MacOSMenu.js new file mode 100644 index 0000000..78770ae --- /dev/null +++ b/src/main/MacOSMenu.js @@ -0,0 +1,50 @@ +// Include the standard keyboard shortcuts in the edit menu +// so they can be used within the app. Only needed on Mac. +export default app => ([ + { + label: 'App', // Always overridden by app name + submenu: [{ + label: 'Quit', + accelerator: 'CmdOrCtrl+Q', + click: () => app.quit() + }] + }, + { + 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' + } + ] + } +]); diff --git a/src/main/index.js b/src/main/index.js index 8d4443f..4e9f415 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -1,7 +1,8 @@ -import {BrowserWindow, app, dialog} from 'electron'; +import {BrowserWindow, Menu, app, dialog} from 'electron'; import * as path from 'path'; import {format as formatUrl} from 'url'; import telemetry from './ScratchDesktopTelemetry'; +import MacOSMenu from './MacOSMenu'; telemetry.appWasOpened(); @@ -20,6 +21,11 @@ const createMainWindow = () => { }); const webContents = window.webContents; + if (process.platform === 'darwin') { + const osxMenu = Menu.buildFromTemplate(MacOSMenu(app)); + Menu.setApplicationMenu(osxMenu); + } + if (isDevelopment) { webContents.openDevTools(); import('electron-devtools-installer').then(importedModule => {