Files: b2886f60b5b31141643c0ea134c62b9e8e0db8e2 / lib / context-menu.js
1253 bytesRaw
1 | var electron = require('electron') |
2 | var Menu = electron.remote.Menu |
3 | var MenuItem = electron.remote.MenuItem |
4 | var BrowserWindow = electron.remote.BrowserWindow |
5 | |
6 | window.addEventListener('contextmenu', function (e) { |
7 | module.exports(null, e) |
8 | }, false) |
9 | |
10 | module.exports = function (item, ev) { |
11 | ev.preventDefault() |
12 | ev.stopPropagation() |
13 | var menu = new Menu() |
14 | menu.append(new MenuItem({ |
15 | label: 'Reload', |
16 | click: function (item, focusedWindow) { |
17 | if (focusedWindow) { |
18 | focusedWindow.reload() |
19 | } |
20 | } |
21 | })) |
22 | menu.append(new MenuItem({ |
23 | type: 'separator' |
24 | })) |
25 | menu.append(new MenuItem({ |
26 | label: 'Inspect Element', |
27 | click: function () { |
28 | var x = ev.clientX |
29 | var y = ev.clientY |
30 | BrowserWindow.getFocusedWindow().inspectElement(x, y) |
31 | } |
32 | })) |
33 | menu.append(new MenuItem({ |
34 | label: 'Inspect Server Process', |
35 | click: function () { |
36 | electron.ipcRenderer.send('open-background-devtools') |
37 | } |
38 | })) |
39 | if (item && item.key) { |
40 | menu.append(new MenuItem({ |
41 | type: 'separator' |
42 | })) |
43 | menu.append(new MenuItem({ |
44 | label: 'Copy Message ID', |
45 | click: function () { |
46 | electron.clipboard.writeText(item.key) |
47 | } |
48 | })) |
49 | } |
50 | |
51 | menu.popup(electron.remote.getCurrentWindow()) |
52 | } |
53 |
Built with git-ssb-web