From e830bfa1bf6d6eb79ded4715a5e10b5ddeb4337a Mon Sep 17 00:00:00 2001 From: Viktor Pasynok Date: Wed, 1 Feb 2017 18:49:21 +0300 Subject: [PATCH] Global shortcut for newShot --- main.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/main.js b/main.js index a207e4a..d27c361 100644 --- a/main.js +++ b/main.js @@ -72,7 +72,30 @@ if (shouldQuit) { app.on('ready', () => { tray = new Tray(__dirname + '/icon.png'); createWindow(); + + const globalShot = globalShortcut.register('CommandOrControl+Alt+M', () => { + if (appFirstStart) { + app.createShot = true; + appWindow.webContents.send('new'); + appWindow.setPosition(0,0); + appWindow.show(); + appWindow.focus(); + appFirstStart = false; + return; + } + dialog.showMessageBox(newShotDialog, function(index) { + // если пользователь подтвердил выбор — далем новый скриншот + if (index === 0) { + app.createShot = true; + appWindow.webContents.send('new'); + appWindow.setPosition(0,0); + appWindow.show(); + appWindow.focus(); + } + }) + }) + const template = appMenu(app, appWindow); const menu = Menu.buildFromTemplate(template);