Files: ab05441c8dcd6cad002d31650852562da523e0c2 / context-menu.js
622 bytesRaw
1 | const electron = require('electron') |
2 | const remote = electron.remote |
3 | const Menu = remote.Menu |
4 | |
5 | var rightClickPosition = null |
6 | |
7 | const menu = Menu.buildFromTemplate([ |
8 | { label: 'Inspect Element', |
9 | click: () => { |
10 | remote.getCurrentWindow().inspectElement(rightClickPosition.x, rightClickPosition.y) |
11 | } |
12 | }, |
13 | { label: 'Inspect Background Process', |
14 | click: () => { |
15 | electron.ipcRenderer.send('open-background-devtools') |
16 | } |
17 | } |
18 | ]) |
19 | |
20 | window.addEventListener('contextmenu', (e) => { |
21 | e.preventDefault() |
22 | rightClickPosition = {x: e.x, y: e.y} |
23 | menu.popup(remote.getCurrentWindow(), {async: true}) |
24 | }, false) |
25 |
Built with git-ssb-web