mirror of
https://github.com/dscalzi/HeliosLauncher.git
synced 2024-12-22 11:42:14 -08:00
Added Application Menu for macOS (#19)
This commit is contained in:
parent
684e884d9c
commit
9d5f708dfc
66
index.js
66
index.js
@ -1,5 +1,6 @@
|
|||||||
// Requirements
|
// Requirements
|
||||||
const {app, BrowserWindow, ipcMain} = require('electron')
|
const {app, BrowserWindow, ipcMain} = require('electron')
|
||||||
|
const Menu = require('electron').Menu
|
||||||
const autoUpdater = require('electron-updater').autoUpdater
|
const autoUpdater = require('electron-updater').autoUpdater
|
||||||
const ejse = require('ejs-electron')
|
const ejse = require('ejs-electron')
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
@ -123,6 +124,70 @@ function createWindow() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createMenu() {
|
||||||
|
|
||||||
|
if(process.platform === 'darwin') {
|
||||||
|
|
||||||
|
// Extend default included application menu to continue support for quit keyboard shortcut
|
||||||
|
let applicationSubMenu = {
|
||||||
|
label: 'Application',
|
||||||
|
submenu: [{
|
||||||
|
label: 'About Application',
|
||||||
|
selector: 'orderFrontStandardAboutPanel:'
|
||||||
|
}, {
|
||||||
|
type: 'separator'
|
||||||
|
}, {
|
||||||
|
label: 'Quit',
|
||||||
|
accelerator: 'Command+Q',
|
||||||
|
click: () => {
|
||||||
|
app.quit()
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
|
||||||
|
// New edit menu adds support for text-editing keyboard shortcuts
|
||||||
|
let editSubMenu = {
|
||||||
|
label: 'Edit',
|
||||||
|
submenu: [{
|
||||||
|
label: 'Undo',
|
||||||
|
accelerator: 'CmdOrCtrl+Z',
|
||||||
|
selector: 'undo:'
|
||||||
|
}, {
|
||||||
|
label: 'Redo',
|
||||||
|
accelerator: 'Shift+CmdOrCtrl+Z',
|
||||||
|
selector: 'redo:'
|
||||||
|
}, {
|
||||||
|
type: 'separator'
|
||||||
|
}, {
|
||||||
|
label: 'Cut',
|
||||||
|
accelerator: 'CmdOrCtrl+X',
|
||||||
|
selector: 'cut:'
|
||||||
|
}, {
|
||||||
|
label: 'Copy',
|
||||||
|
accelerator: 'CmdOrCtrl+C',
|
||||||
|
selector: 'copy:'
|
||||||
|
}, {
|
||||||
|
label: 'Paste',
|
||||||
|
accelerator: 'CmdOrCtrl+V',
|
||||||
|
selector: 'paste:'
|
||||||
|
}, {
|
||||||
|
label: 'Select All',
|
||||||
|
accelerator: 'CmdOrCtrl+A',
|
||||||
|
selector: 'selectAll:'
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bundle submenus into a single template and build a menu object with it
|
||||||
|
let menuTemplate = [applicationSubMenu, editSubMenu]
|
||||||
|
let menuObject = Menu.buildFromTemplate(menuTemplate)
|
||||||
|
|
||||||
|
// Assign it to the application
|
||||||
|
Menu.setApplicationMenu(menuObject)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function getPlatformIcon(filename){
|
function getPlatformIcon(filename){
|
||||||
const opSys = process.platform
|
const opSys = process.platform
|
||||||
if (opSys === 'darwin') {
|
if (opSys === 'darwin') {
|
||||||
@ -137,6 +202,7 @@ function getPlatformIcon(filename){
|
|||||||
}
|
}
|
||||||
|
|
||||||
app.on('ready', createWindow)
|
app.on('ready', createWindow)
|
||||||
|
app.on('ready', createMenu)
|
||||||
|
|
||||||
app.on('window-all-closed', () => {
|
app.on('window-all-closed', () => {
|
||||||
// On macOS it is common for applications and their menu bar
|
// On macOS it is common for applications and their menu bar
|
||||||
|
Loading…
Reference in New Issue
Block a user