From 0ed0e16223c99c30681fdb4c4f516797cec490d1 Mon Sep 17 00:00:00 2001 From: Yuya Ochiai Date: Wed, 7 Oct 2015 23:28:22 +0900 Subject: [PATCH] =?UTF-8?q?Windows=E3=81=A7=E9=96=89=E3=81=98=E3=82=8B?= =?UTF-8?q?=E3=83=9C=E3=82=BF=E3=83=B3=E3=82=92=E6=8A=BC=E3=81=97=E3=81=9F?= =?UTF-8?q?=E5=A0=B4=E5=90=88=E3=81=AB=E3=81=AF=E3=82=A6=E3=82=A3=E3=83=B3?= =?UTF-8?q?=E3=83=89=E3=82=A6=E3=82=92=E6=9C=80=E5=B0=8F=E5=8C=96=E3=81=97?= =?UTF-8?q?=E3=80=81=E7=B5=82=E4=BA=86=E3=81=97=E3=81=9F=E3=81=84=E5=A0=B4?= =?UTF-8?q?=E5=90=88=E3=81=AFCtrl+Q=E3=82=92=E4=BD=BF=E7=94=A8=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/main.js b/main.js index 3a9d94d5..6a47e1cc 100644 --- a/main.js +++ b/main.js @@ -3,10 +3,12 @@ var app = require('app'); // Module to control application life. var BrowserWindow = require('browser-window'); // Module to create native browser window. var ipc = require('ipc'); +var Menu = require('menu'); // Keep a global reference of the window object, if you don't, the window will // be closed automatically when the JavaScript object is garbage collected. var mainWindow = null; +var willAppQuit = false; // Quit when all windows are closed. app.on('window-all-closed', function() { @@ -45,6 +47,35 @@ app.on('ready', function() { } }); + mainWindow.on('close', function(event){ + // Minimize the window for close button. + if(process.platform==='win32'){ + if(!willAppQuit){ // for Ctrl+Q + event.preventDefault(); + mainWindow.minimize(); + } + } + }); + + if(process.platform==='win32'){ + var menu = Menu.buildFromTemplate([ + { + label: 'File', + submenu: [ + { + label: 'Quit', + accelerator: 'Ctrl + Q', + click: function(item, focusedWindow){ + willAppQuit = true; + app.quit(); + } + } + ] + } + ]); + Menu.setApplicationMenu(menu); + } + // Emitted when the window is closed. mainWindow.on('closed', function() { // Dereference the window object, usually you would store windows