From 6dc396dec45364ba466ee56936b4b3574ab00093 Mon Sep 17 00:00:00 2001 From: Wesley van der Sanden Date: Mon, 9 Oct 2017 23:06:54 +0200 Subject: [PATCH] Change switch server implementation Now uses the before-input-event instead of a globalShortcut. GH-512 --- src/main.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main.js b/src/main.js index 63ed9c16..66ede7ed 100644 --- a/src/main.js +++ b/src/main.js @@ -8,8 +8,7 @@ const { nativeImage, dialog, systemPreferences, - session, - globalShortcut + session } = require('electron'); const isDev = require('electron-is-dev'); const installExtension = require('electron-devtools-installer'); @@ -345,12 +344,15 @@ app.on('ready', () => { // Add Alt+Cmd+(Right|Left) as alternative to switch between servers if (process.platform === 'darwin') { - globalShortcut.register('Alt+Cmd+Right', () => { - mainWindow.webContents.send('select-next-tab'); - }); - - globalShortcut.register('Alt+Cmd+Left', () => { - mainWindow.webContents.send('select-previous-tab'); + mainWindow.webContents.on('before-input-event', (event, input) => { + if (input.alt && input.meta) { + if (input.key === 'ArrowRight') { + mainWindow.webContents.send('select-next-tab'); + } + if (input.key === 'ArrowLeft') { + mainWindow.webContents.send('select-previous-tab'); + } + } }); }