0b79e49452
Has Cut, Copy, Paste, and when in developer mode there's also Inspect Element
36 lines
643 B
JavaScript
36 lines
643 B
JavaScript
const {Menu} = require('electron');
|
|
const electron = require('electron');
|
|
const app = electron.app;
|
|
|
|
const contextMenuTemplate = [
|
|
{
|
|
role: 'cut',
|
|
},
|
|
{
|
|
role: 'copy',
|
|
},
|
|
{
|
|
role: 'paste',
|
|
},
|
|
];
|
|
|
|
module.exports = {
|
|
showContextMenu(win, posX, posY, showDevItems) {
|
|
let template = contextMenuTemplate.slice();
|
|
if (showDevItems) {
|
|
template.push({
|
|
type: 'separator',
|
|
});
|
|
template.push(
|
|
{
|
|
label: 'Inspect Element',
|
|
click() {
|
|
win.inspectElement(posX, posY);
|
|
}
|
|
}
|
|
);
|
|
}
|
|
|
|
Menu.buildFromTemplate(template).popup(win);
|
|
},
|
|
};
|