Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 966
Setyl Avatar asked Dec 09 '22 07:12

Setyl


1 Answers

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());
like image 117
Anthony Bobenrieth Avatar answered Dec 20 '22 12:12

Anthony Bobenrieth