Merge pull request #20 from LLK/fix-mac-shortcuts

Include menu with default keyboard shortcuts to allow mac to work
This commit is contained in:
Paul Kaplan 2018-12-27 15:01:38 -05:00 committed by GitHub
commit a7519d167d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 57 additions and 1 deletions

50
src/main/MacOSMenu.js Normal file
View file

@ -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'
}
]
}
]);

View file

@ -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 => {