Disabling SDK context menu options.

I 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) => { 
      return false;

Author: Fantashit

2 thoughts on “Disabling SDK context menu options.

  1. @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.

Comments are closed.