mirror of
https://github.com/balena-io/etcher.git
synced 2025-04-24 07:17:18 +00:00
Prevent global shorcuts from interferring with other applications (#433)
Fixes: https://github.com/resin-io/etcher/issues/389 Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
This commit is contained in:
parent
2948d13075
commit
6af2bd0d30
@ -63,8 +63,22 @@ electron.app.on('ready', function() {
|
||||
mainWindow = null;
|
||||
});
|
||||
|
||||
electron.globalShortcut.register('CmdOrCtrl+Alt+I', function() {
|
||||
mainWindow.webContents.openDevTools();
|
||||
// For some reason, Electron shortcuts are registered
|
||||
// globally, which means that the app listers for shorcuts
|
||||
// even if its not currently focused, potentially interferring
|
||||
// with shorcuts registered by other applications.
|
||||
// As a workaround, we register all shortcuts when the windows
|
||||
// gains focus, and unregister them when the windows loses focus.
|
||||
// See http://electron.atom.io/docs/api/global-shortcut/
|
||||
|
||||
mainWindow.on('focus', function() {
|
||||
electron.globalShortcut.register('CmdOrCtrl+Alt+I', function() {
|
||||
mainWindow.webContents.openDevTools();
|
||||
});
|
||||
});
|
||||
|
||||
mainWindow.on('blur', function() {
|
||||
electron.globalShortcut.unregisterAll();
|
||||
});
|
||||
|
||||
mainWindow.loadURL(`file://${path.join(__dirname, 'index.html')}`);
|
||||
|
Loading…
x
Reference in New Issue
Block a user