Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppressing context menu in OSX #4

Closed
marklieberman opened this issue Apr 25, 2017 · 15 comments
Closed

Suppressing context menu in OSX #4

marklieberman opened this issue Apr 25, 2017 · 15 comments

Comments

@marklieberman
Copy link
Owner

The context menu is not suppressed in OSX because the context menu event fires on mouse down.

On Windows, it fires on mouse up. This affords me the ability to suppress the contextmenu event if a gesture has started.

This is a problem on OSX because at the time when contextmenu event is fired I do not know if a gestures has started. If I choose to preventDefault() the context menu, I cannot trigger the contextmenu event again using pure JavaScript or WE APIs.

The only workaround I can think of is a modifier key to either enable or disable gestures, and then only suppress the context menu when the modifier key is pressed.

@nt1m
Copy link

nt1m commented Apr 26, 2017

Perhaps you should watch on click event, and use event.button to determine which mouse button was used.

@marklieberman
Copy link
Owner Author

marklieberman commented Apr 26, 2017

The gesture button is already configurable. The problem is that in OSX - at the time when contextmenu event is fired - I don't know if the user will do a gesture or not. So, I cannot event.preventDefault() or I may break the context menu for the user.

@nt1m
Copy link

nt1m commented Apr 26, 2017

@marklieberman Instead of contextmenu, can't you simply rely on the mousedown or click event?

Then you can check if it was using right click using event.button.

@marklieberman
Copy link
Owner Author

marklieberman commented Apr 26, 2017

If the user does:
Right button down, right button up - then I still want to show the context menu.

If the user does:
Right button down, mouse move, right button up - then I want to suppress the context menu because they did a gesture.

In Windows the events are in this order:
mousedown -> mouse move -> mouseup -> contextmenu

In OSX the events are in this order:
mousedown -> contextmenu -> mousemove -> mouseup

As you can see, I need contextmenu to be after mousemove in order to know if the user started a gesture or not because I have to decide when to call event.preventDefault() in contextmenu.

@nt1m
Copy link

nt1m commented Apr 27, 2017

On my side, no events are triggered at all when doing two finger (=context menu) gesture, which might be the issue.

@marklieberman
Copy link
Owner Author

That's very strange, because it works fine on my Macbook on FF53 aside from the context menu getting in the way. You just have to go left or up to avoid the context menu.

What about if you change the gesture button to Left?

@nt1m
Copy link

nt1m commented Apr 27, 2017

Left just works fine, but I'm guessing this issue is about the one I reported while reviewing your addon.

@marklieberman
Copy link
Owner Author

Closing for #10. See also: https://bugzilla.mozilla.org/show_bug.cgi?id=1360278

@MurzNN
Copy link

MurzNN commented Jun 7, 2017

Same problem is on Linux system too - when I do a right click - menu is shown and breaks Gesture functionality :( As workaround we can stay FireGestures plugin active (with disabled gesture) that disable instant menu showing, and use it together with new Foxy Gestures :)

@kafene
Copy link

kafene commented Jun 26, 2017

I was just trying to figure out a way to capture a contextmenu event and then re-dispatching to the original target it on mouseup but I can't get anything to work. Seems like once preventDefault is called, it's dead, and impossible to reuse, even by screwing around with Object.defineProperty to make it look like it hasn't been canceled. Using stopPropagation or stopImmediatePropagation were no help either and didn't actually inhibit the context menu from showing.

Some gesture extensions inhibit the context menu, but require a double click to open it. That might be worth looking into. I know SmartUp gestures (not open source) does this. It's a significant impediment to anyone's workflow, until they eventually get used to it.

@marklieberman
Copy link
Owner Author

@kafene Unfortunately, there is no way to programmatically open the content menu. The best solution is to submit a patch to implement https://bugzilla.mozilla.org/show_bug.cgi?id=1360278 but I don't have any experience building Firefox. I do want to spend time learning how to do it, I just don't have free time at the moment.

The potential workarounds I was going to implement are: 1) smartUp style double-right click, 2) use a modifier key to disable gestures, 3) use a modifier key to perform a gesture.

@kafene
Copy link

kafene commented Jun 26, 2017

I don't have any experience building Firefox. I do want to spend time learning how to do it.

Same here. I will look into it. I bet it would be a great thing to have on my resume but this is kind of a hard-mode bug for me because I'll have to learn how to build and test Firefox. Not sure if that's going to happen.

I do know a lot about XPCOM/XUL and the Firefox "inner platform" from writing old extensions; maybe it can be implemented as a WebExtension experiment, although I think those are mainly for implementing new WebExtension features, and Andy McKay has declared that a WebExtension API to open the context menu has no use case. For now, I will start exploring and see if I can even find the code that would handle this.

Brainstorming here - if I do implement this as a pref, I'm thinking it would be like this:

// How to handle right click events in the browser
// 0 = follow platform convention (default; Mac and Linux trigger on mousedown).
// 1 = ignore platform convention; always trigger on mouseup.
// 2 = ignore platform convention; always trigger on mousedown.
pref("browser.contextmenu.behavior", 0);

If there's any Firefox bug I want to tackle, it's this one, since mouse gestures are a non-negotiable part of my workflow. I blame Jon von Tetzchner.

In the meantime - I think the double-click trigger is the best option to prioritize. To be honest one main reason I use mouse gestures a lot is because I'm reclined in my chair and lazy to reach to the keyboard to use keyboard shortcuts.

Also thank you for your hard work on this extension.

Edit: for anyone reading this, a patch has been submitted to Bugzilla: https://bugzilla.mozilla.org/show_bug.cgi?id=1360278#c9

@marklieberman
Copy link
Owner Author

marklieberman commented Jun 26, 2017

@kafene Thanks for looking into this. If you manage to implement this pref that would be amazing. BTW, I'm the reporter on the bugzilla bug.

@stribor
Copy link

stribor commented Oct 17, 2017

In crxMouse Gestures on Chrome what they did is an option to show context menu on double rmb click and use single rmb for gestures.
And I kinda learned to leave with this as I more frequently use mouse gestures than context menu.

@Lamecarlate
Copy link

This night there was an update for Firefox on Ubuntu. Firefox itself still says only "57.0" in the help box, but apt-cache show firefox says "57.0+build4-0ubuntu0.17.10.6". And… the context menu is gone when we trigger a FoxyGestures gesture!

(well, it's also gone 90% of the time, but at least FoxyGestures is pretty well like was FireGestures for me!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants