git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Tree: 004f2ddc8ef2642ade2793f2479573826aaae30b

Files: 004f2ddc8ef2642ade2793f2479573826aaae30b / lib / context-menu.js

1253 bytesRaw
1var electron = require('electron')
2var Menu = electron.remote.Menu
3var MenuItem = electron.remote.MenuItem
4var BrowserWindow = electron.remote.BrowserWindow
5
6window.addEventListener('contextmenu', function (e) {
7 module.exports(null, e)
8}, false)
9
10module.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