MOBILE-2986 desktop: Adapt shortcut to platform for dev tools

main
Dani Palou 2019-05-07 15:16:39 +02:00
parent 29b959e0f8
commit 046fc79719
1 changed files with 5 additions and 4 deletions

View File

@ -6,6 +6,7 @@ const url = require('url');
const fs = require('fs');
const os = require('os');
const userAgent = 'MoodleMobile';
const isMac = os.platform().indexOf('darwin') != -1;
// 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.
@ -69,10 +70,10 @@ function createWindow() {
// Append some text to the user agent.
mainWindow.webContents.setUserAgent(mainWindow.webContents.getUserAgent() + ' ' + userAgent);
// Add shortcut to open dev tools: Control/Cmd + Alt + I.
// Add shortcut to open dev tools: Cmd + Option + I in MacOS, Ctrl + Shift + I in Windows/Linux.
mainWindow.webContents.on('before-input-event', function(e, input) {
// The "meta" key is Cmd in MacOS and Control in Windows/Linux.
if (input.type == 'keyDown' && !input.isAutoRepeat && input.code == 'KeyI' && input.alt && input.meta) {
if (input.type == 'keyDown' && !input.isAutoRepeat && input.code == 'KeyI' &&
((isMac && input.alt && input.meta) || (!isMac && input.shift && input.control))) {
mainWindow.webContents.toggleDevTools();
}
}, true)
@ -83,7 +84,7 @@ function createWindow() {
// See https://github.com/electron/electron/issues/15958
var gotTheLock = app.requestSingleInstanceLock();
if (!gotTheLock && os.platform().indexOf('darwin') == -1) {
if (!gotTheLock && !isMac) {
// It's not the main instance of the app, kill it.
app.exit();
return;