From d85714c01086a76d03fe48ed8ba172a3b135e759 Mon Sep 17 00:00:00 2001 From: Yuya Ochiai Date: Sat, 10 Oct 2015 17:26:07 +0900 Subject: [PATCH] =?UTF-8?q?OS=20X=E3=81=A7=E3=81=AF=E3=83=A1=E3=82=A4?= =?UTF-8?q?=E3=83=B3=E3=82=A6=E3=82=A3=E3=83=B3=E3=83=89=E3=82=A6=E3=82=92?= =?UTF-8?q?=E9=96=89=E3=81=98=E3=82=8B=E4=BB=A3=E3=82=8F=E3=82=8A=E3=81=AB?= =?UTF-8?q?=E9=9A=A0=E3=81=97=E3=80=81=E3=83=89=E3=83=83=E3=82=AF=E3=82=A2?= =?UTF-8?q?=E3=82=A4=E3=82=B3=E3=83=B3=E3=82=92=E3=82=AF=E3=83=AA=E3=83=83?= =?UTF-8?q?=E3=82=AF=E3=81=97=E3=81=9F=E6=99=82=E3=81=AB=E5=86=8D=E8=A1=A8?= =?UTF-8?q?=E7=A4=BA=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.js | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/main.js b/main.js index 3df4333b..726d4a32 100644 --- a/main.js +++ b/main.js @@ -26,6 +26,15 @@ app.on('browser-window-created', function(event, window){ } }); +// For OSX, show hidden mainWindow when clicking dock icon. +app.on('activate', function(event){ + mainWindow.show(); +}); + +app.on('before-quit', function(){ + willAppQuit = true; +}) + // This method will be called when Electron has finished // initialization and is ready to create browser windows. app.on('ready', function() { @@ -39,11 +48,17 @@ app.on('ready', function() { // mainWindow.openDevTools(); mainWindow.on('close', function(event){ - // Minimize the window for close button. - if(process.platform==='win32'){ - if(!willAppQuit){ // for Ctrl+Q - event.preventDefault(); - mainWindow.minimize(); + // Minimize or hide the window for close button. + if(!willAppQuit){ // avoid [Ctrl|Cmd]+Q + event.preventDefault(); + switch (process.platform) { + case 'win32': + mainWindow.minimize(); + break; + case 'darwin': + mainWindow.hide(); + break; + default: } } }); @@ -63,7 +78,6 @@ app.on('ready', function() { label: 'Quit', accelerator: 'Ctrl + Q', click: function(item, focusedWindow){ - willAppQuit = true; app.quit(); } }