Search code examples
javascriptgoogle-chromecontextmenugoogle-chrome-app

Disable the context menu in chrome apps?


I am trying to write a chrome app which is set to fullscreen and started with Google's getting started tutorial from here: https://developer.chrome.com/apps/first_app

Now i am trying to disable the context menu which appears on right click.

Is that possible? And if so, how? I was searching over and over but couldn't find a solution. Please help!


Solution

  • Chrome context menu only apear on debugging app (loaded from a directory).

    But if you still want to disable context menu on your whole chrome app, simply use preventDefault() on the onContext event of your document... (every your custom context menu ll still work...)

    For js (demo):

    document.addEventListener("contextmenu", function(e) {
    e.preventDefault();
    });
    

    For dart:

    document.onContextMenu.listen((e)=>e.preventDefault());