diff options
| author | Pliable Pixels <pliablepixels@gmail.com> | 2017-02-27 16:24:22 -0500 |
|---|---|---|
| committer | Pliable Pixels <pliablepixels@gmail.com> | 2017-02-27 16:24:22 -0500 |
| commit | 30076df5e3c7f33d9f105625bbc3b98ddadacc2c (patch) | |
| tree | 5b559472536b9d7b534ccbaeb3aa5797b5bbd540 /electron_js | |
| parent | 2cac3f6cfc2466d64b75f50e6a61e0e25298a3e3 (diff) | |
#473 - changed hotkey to Cmd/Ctrl+Alt+F and now it toggles
Diffstat (limited to 'electron_js')
| -rw-r--r-- | electron_js/main.js | 39 |
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() +}); |
