mirror of
https://github.com/scratchfoundation/scratch-desktop.git
synced 2025-01-09 22:22:34 -05:00
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:
commit
a7519d167d
2 changed files with 57 additions and 1 deletions
50
src/main/MacOSMenu.js
Normal file
50
src/main/MacOSMenu.js
Normal 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'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]);
|
|
@ -1,7 +1,8 @@
|
||||||
import {BrowserWindow, app, dialog} from 'electron';
|
import {BrowserWindow, Menu, app, dialog} from 'electron';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import {format as formatUrl} from 'url';
|
import {format as formatUrl} from 'url';
|
||||||
import telemetry from './ScratchDesktopTelemetry';
|
import telemetry from './ScratchDesktopTelemetry';
|
||||||
|
import MacOSMenu from './MacOSMenu';
|
||||||
|
|
||||||
telemetry.appWasOpened();
|
telemetry.appWasOpened();
|
||||||
|
|
||||||
|
@ -20,6 +21,11 @@ const createMainWindow = () => {
|
||||||
});
|
});
|
||||||
const webContents = window.webContents;
|
const webContents = window.webContents;
|
||||||
|
|
||||||
|
if (process.platform === 'darwin') {
|
||||||
|
const osxMenu = Menu.buildFromTemplate(MacOSMenu(app));
|
||||||
|
Menu.setApplicationMenu(osxMenu);
|
||||||
|
}
|
||||||
|
|
||||||
if (isDevelopment) {
|
if (isDevelopment) {
|
||||||
webContents.openDevTools();
|
webContents.openDevTools();
|
||||||
import('electron-devtools-installer').then(importedModule => {
|
import('electron-devtools-installer').then(importedModule => {
|
||||||
|
|
Loading…
Reference in a new issue