1j01 / jspaint

🎨 Classic MS Paint, REVIVED + ✨Extras
https://jspaint.app/about
MIT License
7.22k stars 562 forks source link

Shift+right click opens context menu in Firefox #161

Open 1j01 opened 4 years ago

1j01 commented 4 years ago

Right mouse button is used to access the secondary (background) color, and shift is used to make equal width/height shapes. Shift+right click is clearly an escape hatch for users of Firefox, to access the context menu on sites that block it willy-nilly. I'd like to preserve this ability where it doesn't conflict.

Plan: listen for and prevent contextmenu globally while canvas-related gesture is active. May need a timeout after pointerup if contextmenu comes after pointerup.

This should also fix dragging with right click over a window like About Paint showing a context menu. I'm not sure about the Help window, which uses an iframe to display the content.

This should also let me un-revert setPointerCapture for 98.js.org integration.

AlexHRodrii commented 1 year ago

Since some firefox updates is impossible to absolutely disable the context menu because if you disable it firefox core automatically sets the context menu shortcut to Shift + Right Click, the user itself can disable it in the firefox settings going to:

Tools > Options > Content > Advanced and the activate 'Enable Javascript' and 'Disable or replace context menus' settings.

Due to this I think this shouldn't be catalogued as 'bug'.

1j01 commented 1 year ago

@AlexHRodrii How do I get to "Tools > Options > Content > Advanced"? What version of Firefox does this apply to?

AlexHRodrii commented 1 year ago

Since the latests firefox updates you need to do aditional steps. Here it's a guide about how to disable the context menus. image

  1. First, open a new tab and write in the navigation bar 'about:config' (accept to enter if a warning pop up is shown)
  2. Then, search for 'dom.event.contextmenu.enabled'
  3. If you want to disable it, set this setting to false
  4. Restart firefox
1j01 commented 1 year ago

Disabling dom.event.contextmenu.enabled appears to disable the contextmenu event entirely, making webpages unable to prevent the context menu in any case, so this wouldn't help anyone looking for a workaround.

I poked around and found some discussion of this on the Firefox bug tracker: 1, 2, 3. There doesn't seem to be many people pointing out use cases, so I might join the discussion. I'm writing my notes here in case I come back to this later:

Two use cases I see, aside from user interfaces that directly use Shift+right click as a gesture, are:

  1. JS Paint, where to draw a circle or square (rather than an ellipse or rectangle) you can hold Shift, and to draw using the secondary ("background") color you can use the right mouse button. There's a work-around, but it's very awkward to have to press RMB, press Shift, drag, release RMB, and then release shift, in that exact order.
  2. A first-person shooter game where you can hold Shift to sprint, and right click for a secondary attack such as melee. A context menu popping up would get you killed for sure. (Maybe the pointer lock API gets around this, I don't know.)