Skip to content

Commit

Permalink
feat: context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
feildmaster committed Dec 31, 2020
1 parent 9544a8c commit ac919ec
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
17 changes: 13 additions & 4 deletions src/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
Expand All @@ -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();
}
Expand Down Expand Up @@ -73,4 +82,4 @@ app.on('window-all-closed', () => {
});


module.exports = (dir) => app.whenReady().then(() => createWindow(dir));
module.exports = () => app.whenReady().then(() => createWindow());

0 comments on commit ac919ec

Please sign in to comment.