MOBILE-2986 desktop: Adapt shortcut to platform for dev tools
parent
29b959e0f8
commit
046fc79719
|
@ -6,6 +6,7 @@ const url = require('url');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
const userAgent = 'MoodleMobile';
|
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
|
// 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.
|
// be closed automatically when the JavaScript object is garbage collected.
|
||||||
|
@ -69,10 +70,10 @@ function createWindow() {
|
||||||
// Append some text to the user agent.
|
// Append some text to the user agent.
|
||||||
mainWindow.webContents.setUserAgent(mainWindow.webContents.getUserAgent() + ' ' + userAgent);
|
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) {
|
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' &&
|
||||||
if (input.type == 'keyDown' && !input.isAutoRepeat && input.code == 'KeyI' && input.alt && input.meta) {
|
((isMac && input.alt && input.meta) || (!isMac && input.shift && input.control))) {
|
||||||
mainWindow.webContents.toggleDevTools();
|
mainWindow.webContents.toggleDevTools();
|
||||||
}
|
}
|
||||||
}, true)
|
}, true)
|
||||||
|
@ -83,7 +84,7 @@ function createWindow() {
|
||||||
// See https://github.com/electron/electron/issues/15958
|
// See https://github.com/electron/electron/issues/15958
|
||||||
var gotTheLock = app.requestSingleInstanceLock();
|
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.
|
// It's not the main instance of the app, kill it.
|
||||||
app.exit();
|
app.exit();
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue