git ssb

10+

Matt McKegg / patchwork



Tree: 13be5ee9906beb5d8c2a24db46c68ef183c78d3a

Files: 13be5ee9906beb5d8c2a24db46c68ef183c78d3a / lib / context-menu.js

1028 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
34 if (item && item.key) {
35 menu.append(new MenuItem({
36 label: 'Copy Message ID',
37 click: function () {
38 electron.clipboard.writeText(item.key)
39 }
40 }))
41 }
42
43 menu.popup(electron.remote.getCurrentWindow())
44}
45

Built with git-ssb-web