Electron WebContents context-menu

The solution for “Electron WebContents context-menu” can be found here. The following code will assist you in solving the problem.

var menu = new Menu();

//Basic Menu For Testing
menu.append(new MenuItem({ label: ‘MenuItem1’, click: function() { console.log(“YES”);
} }));
menu.append(new MenuItem({ type: ‘separator’ }));
menu.append(new MenuItem({ label: ‘MenuItem2’, type: ‘checkbox’, checked: true }));
app.on(“web-contents-created”, (…[/* event */, webContents]) => {

//Webview is being shown here as a window type
console.log(webContents.getType())
webContents.on(“context-menu”, (event, click) => {
event.preventDefault();
console.log(webContents.getType())
menu.popup(webContents);
}, false);
});

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

0
inline scripts encapsulated in