-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrenderer.js
37 lines (32 loc) · 1.05 KB
/
renderer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// This file is required by the index.html file and will
// be executed in the renderer process for that window.
// All of the Node.js APIs are available in this process.
const isDev = /[\\/]electron[\\/]/.test(process.execPath)
const remote = require('electron').remote
const Menu = remote.Menu
const MenuItem = remote.MenuItem
var rightClickPosition = null
const menu = new Menu()
const menuItem = new MenuItem({
label: 'Inspect Element',
click: function() {
remote.getCurrentWindow().inspectElement(rightClickPosition.x, rightClickPosition.y)
}
})
menu.append(menuItem)
window.addEventListener('contextmenu', function(event) {
event.preventDefault()
rightClickPosition = {
x: event.x,
y: event.y
}
menu.popup(remote.getCurrentWindow())
}, false)
if(isDev) {
var electronDevToolsInstaller = require('electron-devtools-installer')
electronDevToolsInstaller.default(electronDevToolsInstaller.REACT_DEVELOPER_TOOLS).then(function(name) {
console.log('Loaded something: ', name)
}).catch(function(err) {
console.log('Error loading something: ', err)
})
}