dev toools: separate shortcut for electron and for web content
This commit is contained in:
parent
804e2ff39a
commit
cca80cd992
2 changed files with 23 additions and 7 deletions
|
@ -9,7 +9,6 @@
|
||||||
const Menu = require('electron').Menu;
|
const Menu = require('electron').Menu;
|
||||||
// Node fs module
|
// Node fs module
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
|
|
||||||
var template;
|
var template;
|
||||||
|
|
||||||
template = [
|
template = [
|
||||||
|
@ -76,7 +75,20 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Toggle Developer Tools',
|
label: 'Electron Developer Tools',
|
||||||
|
accelerator: (function() {
|
||||||
|
if (process.platform == 'darwin')
|
||||||
|
return 'Alt+Command+E';
|
||||||
|
else
|
||||||
|
return 'Ctrl+Shift+E';
|
||||||
|
})(),
|
||||||
|
click: function(item, focusedWindow) {
|
||||||
|
if (focusedWindow)
|
||||||
|
focusedWindow.toggleDevTools();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Web Developer Tools',
|
||||||
accelerator: (function() {
|
accelerator: (function() {
|
||||||
if (process.platform == 'darwin')
|
if (process.platform == 'darwin')
|
||||||
return 'Alt+Command+I';
|
return 'Alt+Command+I';
|
||||||
|
@ -84,10 +96,11 @@
|
||||||
return 'Ctrl+Shift+I';
|
return 'Ctrl+Shift+I';
|
||||||
})(),
|
})(),
|
||||||
click: function(item, focusedWindow) {
|
click: function(item, focusedWindow) {
|
||||||
if (focusedWindow)
|
if ( focusedWindow ) {
|
||||||
focusedWindow.toggleDevTools();
|
focusedWindow.webContents.send( 'openDevTools' );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -183,7 +196,6 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
app.on('ready', function() {
|
app.on('ready', function() {
|
||||||
|
|
||||||
var menu = Menu.buildFromTemplate(template);
|
var menu = Menu.buildFromTemplate(template);
|
||||||
Menu.setApplicationMenu(menu);
|
Menu.setApplicationMenu(menu);
|
||||||
const initPath = __dirname + "/init.json";
|
const initPath = __dirname + "/init.json";
|
||||||
|
@ -197,7 +209,7 @@
|
||||||
console.log('Unable to read init.json: ', e);
|
console.log('Unable to read init.json: ', e);
|
||||||
}
|
}
|
||||||
const bounds = (data && data.bounds) ? data.bounds : {width: 1280, height:800 };
|
const bounds = (data && data.bounds) ? data.bounds : {width: 1280, height:800 };
|
||||||
var bwdata = {width: bounds.width, height: bounds.height, 'min-width': 1024, 'min-height': 600, 'autoHideMenuBar': true, 'web-security': true, 'java': false, 'accept-first-mouse': true, defaultEncoding: 'UTF-8', 'icon':'file://'+__dirname + '/assets/img/favicon.png'}
|
var bwdata = {width: bounds.width, height: bounds.height, 'min-width': 1024, 'min-height': 600, 'autoHideMenuBar': true, 'web-security': true, 'java': false, 'accept-first-mouse': true, defaultEncoding: 'UTF-8', 'icon':'file://'+__dirname + '/assets/img/favicon.png'};
|
||||||
// Remembe window position
|
// Remembe window position
|
||||||
if (data && data.bounds.x && data.bounds.y) {
|
if (data && data.bounds.x && data.bounds.y) {
|
||||||
bwdata.x = data.bounds.x;
|
bwdata.x = data.bounds.x;
|
||||||
|
|
|
@ -24,6 +24,10 @@ onload = function() {
|
||||||
webview.addEventListener("new-window", handlenewwindow);
|
webview.addEventListener("new-window", handlenewwindow);
|
||||||
webview.addEventListener("page-title-set", handletitleset);
|
webview.addEventListener("page-title-set", handletitleset);
|
||||||
|
|
||||||
|
ipc.on('openDevTools', function() {
|
||||||
|
setTimeout(function() { webview.openDevTools(); }, 0 );
|
||||||
|
});
|
||||||
|
|
||||||
ipc.on('browser-window-focus', function() {
|
ipc.on('browser-window-focus', function() {
|
||||||
setTimeout(function() { webview.focus(); }, 0);
|
setTimeout(function() { webview.focus(); }, 0);
|
||||||
setTimeout(function() { webview.executeJavaScript("document.getElementById(\"sendMessage\").focus();") }, 0);
|
setTimeout(function() { webview.executeJavaScript("document.getElementById(\"sendMessage\").focus();") }, 0);
|
||||||
|
|
Loading…
Reference in a new issue