Skip to content

Commit ac919ec

Browse files
committed
feat: context menu
1 parent 9544a8c commit ac919ec

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"electron-builder": "^22.9.1"
2121
},
2222
"dependencies": {
23+
"electron-context-menu": "^2.3.1",
2324
"electron-updater": "^4.3.5",
2425
"keytar": "^7.3.0",
2526
"needle": "^2.5.2"

src/electron.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ const { app, BrowserWindow, shell, ipcMain } = require('electron');
22
const path = require('path');
33
const keytar = require('keytar');
44
const { autoUpdater } = require('electron-updater');
5+
const contextMenu = require('electron-context-menu');
56

6-
function createWindow(dir = '') {
7+
function createWindow() {
78
const win = new BrowserWindow({
89
webPreferences: {
910
nodeIntegration: false,
@@ -25,6 +26,16 @@ function createWindow(dir = '') {
2526
}
2627
});
2728
});
29+
30+
contextMenu({
31+
window: win,
32+
showLookUpSelection: false,
33+
showSearchWithGoogle: false,
34+
append: (actions, params, window) => [{
35+
label: 'Toggle fullscreen',
36+
click: () => win.setFullScreen(!win.isFullScreen()),
37+
}],
38+
});
2839

2940
win.loadURL('https://undercards.net/SignIn');
3041
win.setMenu(null);
@@ -34,8 +45,6 @@ function createWindow(dir = '') {
3445
if (input.control && input.shift && input.key.toLowerCase() === 'i') {
3546
event.preventDefault();
3647
win.webContents.openDevTools();
37-
} else if (input.key === 'F11') {
38-
win.setFullScreen(!win.isFullScreen());
3948
} else if (input.key === 'F5' || input.control && input.key.toLowerCase() === 'r') {
4049
win.reload();
4150
}
@@ -73,4 +82,4 @@ app.on('window-all-closed', () => {
7382
});
7483

7584

76-
module.exports = (dir) => app.whenReady().then(() => createWindow(dir));
85+
module.exports = () => app.whenReady().then(() => createWindow());

0 commit comments

Comments
 (0)