summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--electron_js/main.js39
1 files changed, 37 insertions, 2 deletions
diff --git a/electron_js/main.js b/electron_js/main.js
index 7f3a955b..243e1f21 100644
--- a/electron_js/main.js
+++ b/electron_js/main.js
@@ -2,9 +2,14 @@ const electron = require('electron');
const windowStateKeeper = require('electron-window-state');
//require('electron-debug')({showDevTools: true});
// Module to control application life.
-const {app} = electron;
+const {app, globalShortcut} = electron;
// Module to create native browser window.
const {BrowserWindow} = electron;
+var isFs = false;
+
+
+
+
// 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.
@@ -26,10 +31,25 @@ if (shouldQuit) {
function createWindow() {
+
+const mx = globalShortcut.register('CommandOrControl+Alt+F', () => {
+ console.log('CommandOrControl+F is pressed');
+ isFs = !isFs;
+ win.setFullScreen(isFs);
+ })
+
+ const dbgx = globalShortcut.register('CommandOrControl+Alt+D', () => {
+ console.log('CommandOrControl+Alt+D is pressed');
+ win.webContents.openDevTools();
+ })
+
+
// Create the browser window.
let mainWindowState = windowStateKeeper({
defaultWidth: 1000,
- defaultHeight: 800
+ defaultHeight: 800,
+ webPreferences:{nodeIntegration:false}
+
});
//win = new BrowserWindow({width: 1024, height: 900, webPreferences:{nodeIntegration:false}});
win = new BrowserWindow({
@@ -42,7 +62,12 @@ function createWindow() {
mainWindowState.manage(win);
// fs will be arg 1 if its not run in electron debug mode
if (process.argv.slice(1)=='fs' || process.argv.slice(2)=='fs')
+ {
win.setFullScreen(true);
+ isFs = true;
+ }
+
+
// and load the index.html of the app.
win.loadURL(`file://${__dirname}/index.html`);
@@ -64,6 +89,8 @@ function createWindow() {
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow);
+
+
// Quit when all windows are closed.
app.on('window-all-closed', () => {
// On macOS it is common for applications and their menu bar
@@ -80,3 +107,11 @@ app.on('activate', () => {
createWindow();
}
});
+
+app.on('will-quit', () => {
+ // Unregister a shortcut.
+ //globalShortcut.unregister('CommandOrControl+X')
+
+ // Unregister all shortcuts.
+ globalShortcut.unregisterAll()
+});