Closed Bug 1704883 Opened 3 years ago Closed 3 years ago

In native context menus, report the mouse button which was used to click the menu item, to support a WebExtension API

Categories

(Core :: Widget: Cocoa, defect)

defect

Tracking

()

RESOLVED FIXED
90 Branch
Tracking Status
firefox89 --- fixed
firefox90 --- fixed

People

(Reporter: mstange, Assigned: mstange)

References

Details

(Whiteboard: [proton-uplift])

Attachments

(1 file)

Our WebExtension menu items have the ability to detect the mouse button that a context menu item was clicked with: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/menus/OnClickData

This was added in bug 1469148 and is only supported in Firefox.

Do we want to support this capability on macOS with native menus? On macOS, having a menu item behave differently depending on what mouse button it was clicked with is very unexpected... but not impossible.

So I think we have two choices here:

  • Choose not to support it (always report button 0) and disable the test browser_ext_menus_capture_secondary_click.js if native menus are used.
  • Or implement support for it.

Thoughts?

It should ideally be supported, for API consistency across platforms.

Do you have any idea about what it entails to support this functionality?

Test is being disabled (well, changed to fake events that does not match reality) for now in https://phabricator.services.mozilla.com/D111901

See Also: → 1469148, 1704875

This is also used in the search context menu item, shown when in-content text is selected. A middle click does the search in a background tab. This is causing browser/components/search/test/browser/browser_contextmenu_whereToOpenLink.js to fail.

(In reply to Rob Wu [:robwu] from comment #1)

It should ideally be supported, for API consistency across platforms.

Given that it is indeed possible, I can't really argue with that. It's just a bit weird / doesn't conform to macOS platform expectations. But I suppose the "safe" thing to do here is to keep existing functionality working and then have this discussion at some other point in the future.

Do you have any idea about what it entails to support this functionality?

It's not hard, the information is in NSApp.currentEvent.buttonNumber and we just need to forward it to the right place.

Blocks: 1615213

(In reply to Markus Stange [:mstange] from comment #3)

It's not hard, the information is in NSApp.currentEvent.buttonNumber and we just need to forward it to the right place.

It turns out there was a bit of a challenge here, because the current implementation in ext-menus.js gets the button from the click event, and we don't have a click event in native menus. I filed bug 1704948 to find a solution for this.

Blocks: 1704972
Pushed by mstange@themasta.com:
https://hg.mozilla.org/integration/autoland/rev/4a2c06c74c5d
Report which mouse button was used to click items in native menus. r=harry
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 90 Branch
Whiteboard: [proton-uplift]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: