diff --git a/package.json b/package.json index 357efff..4e52a22 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "electron-builder": "^22.9.1" }, "dependencies": { + "electron-context-menu": "^2.3.1", "electron-updater": "^4.3.5", "keytar": "^7.3.0", "needle": "^2.5.2" diff --git a/src/electron.js b/src/electron.js index fdc1bc3..34a2f5f 100644 --- a/src/electron.js +++ b/src/electron.js @@ -2,8 +2,9 @@ const { app, BrowserWindow, shell, ipcMain } = require('electron'); const path = require('path'); const keytar = require('keytar'); const { autoUpdater } = require('electron-updater'); +const contextMenu = require('electron-context-menu'); -function createWindow(dir = '') { +function createWindow() { const win = new BrowserWindow({ webPreferences: { nodeIntegration: false, @@ -25,6 +26,16 @@ function createWindow(dir = '') { } }); }); + + contextMenu({ + window: win, + showLookUpSelection: false, + showSearchWithGoogle: false, + append: (actions, params, window) => [{ + label: 'Toggle fullscreen', + click: () => win.setFullScreen(!win.isFullScreen()), + }], + }); win.loadURL('https://undercards.net/SignIn'); win.setMenu(null); @@ -34,8 +45,6 @@ function createWindow(dir = '') { if (input.control && input.shift && input.key.toLowerCase() === 'i') { event.preventDefault(); win.webContents.openDevTools(); - } else if (input.key === 'F11') { - win.setFullScreen(!win.isFullScreen()); } else if (input.key === 'F5' || input.control && input.key.toLowerCase() === 'r') { win.reload(); } @@ -73,4 +82,4 @@ app.on('window-all-closed', () => { }); -module.exports = (dir) => app.whenReady().then(() => createWindow(dir)); +module.exports = () => app.whenReady().then(() => createWindow());