question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Disabling SDK context menu options.

See original GitHub issue

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) => { 
      e.preventDefault();
      return false;
    });

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
edyseguracommented, Jul 30, 2016

Hi @orther !

To disable these context menu I used the chromium-args below:

image

Hope it can help you!

2reactions
ghostoycommented, Jul 8, 2016

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Disabling or Removing Context Menu Items for a Specific Object
In this example, you disable the Delete context menu item on the Folder Browsing page, but only when the context object is a...
Read more >
How to Enable or disable context menu items in JavaScript ...
You can enable and disable the menu items using the enableItems method in ContextMenu. To enable menuItems, set the enable property in argument...
Read more >
Disable Or Enable Windows 11 Context Menu How To Guide
From Start Menu and Taskbar ->open Disable Context menus in the Start Menu policy setting. Select the Enabled option for disabling the context ......
Read more >
Android: How to enable/disable option menu item on button ...
But I have a button somewhere in screen, and on clicking that button, it should enable/disable context menu items.
Read more >
Disable Windows 11 file context menu. - Microsoft Q&A
I was wondering what API I need to use to access/modify/disable these menu items. thanks! 145274-image.png. windows-11.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found