Files: 572440feaf959755763efb726087066a6f5b29db / lib / context-menu.js
1037 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, null, e) |
8 | }, false) |
9 | |
10 | module.exports = function (context, 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 | |
34 | if (item && item.id) { |
35 | menu.append(new MenuItem({ |
36 | label: 'Copy SSB ID', |
37 | click: function () { |
38 | electron.clipboard.writeText(item.id) |
39 | } |
40 | })) |
41 | } |
42 | |
43 | menu.popup(electron.remote.getCurrentWindow()) |
44 | } |
45 |
Built with git-ssb-web