Disabling SDK context menu options.
See original GitHub issueI am developing an app for OSX and Windows and we recently moved from nwjs v0.12.3 to v0.15.4 SDK build flavor and node v6.2.2. In our app we open the DevTools programmatically or more often use remote debugging. Currently when using the SDK build flavor the following 4 context menu items are added:
- Reload App
- Simulate Browser Restart
- Inspect
- Inspect Background Page
I would like the ability to NOT add these context menu items when using the SDK build. Originally I figured I would solve this by manually setting the handler of the contextmenu
event during window creation (example code below). The problem with this is that there are default context menu items I want to show up (e.g. selected text should have context menu to copy text).
It would be much more straight forward to have a manifest option or method to disable these context menu items. If there are already facilities to manipulate the default context menus programmatically so I could remove only the 4 listed above in my JS code I would settle on that as a good solution and appreciate information on doing so.
Example code used to disable context menus on window creation:
// disable context menu
newWindow.window.document.body.addEventListener('contextmenu', (e) => {
e.preventDefault();
return false;
});
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (2 by maintainers)
Top GitHub Comments
Hi @orther !
To disable these context menu I used the chromium-args below:
Hope it can help you!
@orther Sorry, I misunderstand your request. I’ll look into a fix to let you programmatically remove the 4 devtools items from default context menu.