Skip to content
This repository has been archived by the owner on Apr 29, 2022. It is now read-only.

Commit

Permalink
fix context menu disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
diginatu committed May 12, 2019
1 parent 80907c9 commit d872b79
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 32 deletions.
2 changes: 1 addition & 1 deletion app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<title>Nagome</title>
</head>
<body style="overflow:hidden;">
<webview id="webview" style="position:absolute;left:0;top:0;width:100%;height:100%;">
<webview id="webview" style="position:absolute;left:0;top:0;width:100%;height:100%;" preload="./webview.js">
</webview>
</body>
</html>
18 changes: 0 additions & 18 deletions app/renderer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
const ipc = require('electron').ipcRenderer;
const {remote} = require('electron');
const {Menu} = remote;

window.onload = function() {
const webview = document.getElementById('webview');
Expand All @@ -17,20 +15,4 @@ window.onload = function() {
event.preventDefault();
ipc.send('new-window', e.url);
});

// Context menu
const template = [
{ label: 'Undo', accelerator: 'CmdOrCtrl+Z', role: 'undo' },
{ label: 'Redo', accelerator: 'Shift+CmdOrCtrl+Z', role: 'redo' },
{ type: 'separator' },
{ label: 'Cut', accelerator: 'CmdOrCtrl+X', role: 'cut' },
{ label: 'Copy', accelerator: 'CmdOrCtrl+C', role: 'copy' },
{ label: 'Paste', accelerator: 'CmdOrCtrl+V', role: 'paste' },
{ label: 'Select All', accelerator: 'CmdOrCtrl+A', role: 'selectall' }
];
const menu = Menu.buildFromTemplate(template);
window.addEventListener('contextmenu', (e) => {
e.preventDefault();
menu.popup(remote.getCurrentWindow());
}, false);
}
15 changes: 2 additions & 13 deletions app/browserwindow.js → app/webview.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
const ipc = require('electron').ipcRenderer;
const {remote} = require('electron');
const {Menu, MenuItem} = remote;
const {Menu} = remote;

window.onload = function() {
window.addEventListener('page-title-updated', (e) => {
console.log("page-title-updated: view");
document.title = e.title;
});

window.addEventListener('new-window', (e) => {
event.preventDefault();
ipc.send('new-window', e.url);
});

// Context menu
const template = [
{ label: 'Undo', accelerator: 'CmdOrCtrl+Z', role: 'undo' },
Expand All @@ -28,4 +17,4 @@ window.onload = function() {
e.preventDefault();
menu.popup(remote.getCurrentWindow());
}, false);
};
}

0 comments on commit d872b79

Please sign in to comment.