Skip to content

Commit

Permalink
changes mac closing app behaviour
Browse files Browse the repository at this point in the history
since it's a single-window app, per Apple's Human Interface Guidelines i should probably make the entire app close when the main window closes. so i did that!
  • Loading branch information
mattxwang committed Apr 4, 2018
1 parent ca11b1c commit 07b836b
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 49 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"ignore": ".+.o$",
"appBundleId": "me.matthewwang.fair-chair",
"helperBundleId": "me.matthewwang.fair-chair.helper",
"buildVersion": "1.0.3"
"buildVersion": "1.0.4"
},
"electronWinstallerConfig": {
"name": "fair_chair"
Expand Down
103 changes: 55 additions & 48 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,25 @@ app.on('ready', () => {
app.on('window-all-closed', () => {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit();
}

// Disabled because it causes problems with the toolbar

//if (process.platform !== 'darwin') {
app.quit();
//}
});


// Disabled because it causes problems with the toolbar
/*
app.on('activate', () => {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) {
createWindow();
}
});
*/

// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and import them here.
Expand All @@ -70,14 +77,14 @@ template = [
submenu: [
{
label: 'Import Savefile',
click () {
click() {
mainWindow.webContents.send('to-settings');
mainWindow.webContents.send('import-savefile');
}
},
{
label: 'Export Savefile',
click () {
click() {
mainWindow.webContents.send('to-settings');
mainWindow.webContents.send('export-savefile');
}
Expand All @@ -87,55 +94,55 @@ template = [
{
label: 'Edit',
submenu: [
{role: 'undo'},
{role: 'redo'},
{type: 'separator'},
{role: 'cut'},
{role: 'copy'},
{role: 'paste'},
{role: 'pasteandmatchstyle'},
{role: 'delete'},
{role: 'selectall'}
{ role: 'undo' },
{ role: 'redo' },
{ type: 'separator' },
{ role: 'cut' },
{ role: 'copy' },
{ role: 'paste' },
{ role: 'pasteandmatchstyle' },
{ role: 'delete' },
{ role: 'selectall' }
]
},
{
label: 'View',
submenu: [
{role: 'reload'},
{role: 'forcereload'},
{role: 'toggledevtools'},
{type: 'separator'},
{role: 'resetzoom'},
{role: 'zoomin'},
{role: 'zoomout'},
{type: 'separator'},
{role: 'togglefullscreen'}
{ role: 'reload' },
{ role: 'forcereload' },
{ role: 'toggledevtools' },
{ type: 'separator' },
{ role: 'resetzoom' },
{ role: 'zoomin' },
{ role: 'zoomout' },
{ type: 'separator' },
{ role: 'togglefullscreen' }
]
},
{
label: 'Go',
submenu: [
{
label: 'Home',
click () {
click() {
mainWindow.webContents.send('to-home');
}
},
{
label: 'Lists',
click () {
click() {
mainWindow.webContents.send('to-lists');
}
},
{
label: 'Guide',
click () {
click() {
mainWindow.webContents.send('to-guide');
}
},
{
label: 'Settings',
click () {
click() {
mainWindow.webContents.send('to-settings');
}
},
Expand All @@ -144,20 +151,20 @@ template = [
{
role: 'window',
submenu: [
{role: 'minimize'},
{role: 'close'}
{ role: 'minimize' },
{ role: 'close' }
]
},
{
role: 'help',
submenu: [
{
label: 'Learn More',
click () { require('electron').shell.openExternal('https://electronjs.org') }
click() { require('electron').shell.openExternal('https://electronjs.org') }
},
{
label: 'GitHub Repository',
click () { require('electron').shell.openExternal('https://github.com/malsf21/fair-chair/') }
click() { require('electron').shell.openExternal('https://github.com/malsf21/fair-chair/') }
}
]
}
Expand All @@ -169,36 +176,36 @@ if (process.platform === 'darwin') {
template.unshift({
label: app.getName(),
submenu: [
{role: 'about'},
{type: 'separator'},
{role: 'services', submenu: []},
{type: 'separator'},
{role: 'hide'},
{role: 'hideothers'},
{role: 'unhide'},
{type: 'separator'},
{role: 'quit'}
{ role: 'about' },
{ type: 'separator' },
{ role: 'services', submenu: [] },
{ type: 'separator' },
{ role: 'hide' },
{ role: 'hideothers' },
{ role: 'unhide' },
{ type: 'separator' },
{ role: 'quit' }
]
})

// Edit menu
template[1].submenu.push(
{type: 'separator'},
{ type: 'separator' },
{
label: 'Speech',
submenu: [
{role: 'startspeaking'},
{role: 'stopspeaking'}
{ role: 'startspeaking' },
{ role: 'stopspeaking' }
]
}
)

// Window menu
template[3].submenu = [
{role: 'close'},
{role: 'minimize'},
{role: 'zoom'},
{type: 'separator'},
{role: 'front'}
{ role: 'close' },
{ role: 'minimize' },
{ role: 'zoom' },
{ type: 'separator' },
{ role: 'front' }
]
}

0 comments on commit 07b836b

Please sign in to comment.