Closed Bug 1043435 Opened 10 years ago Closed 3 years ago

popuphiding/popuphidden events in native Mac menus fire before command events

Categories

(Core :: Widget: Cocoa, defect)

All
macOS
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1698997

People

(Reporter: mstange, Unassigned)

Details

This was reported in bug 1037433 comment 31:

(In reply to Florian Quèze [:florian] [:flo] from bug 1037433 comment #31)
> - the "command" event is fired after the "popuphiding" and "popuphidden"
> events, so if the menu is cleaned up in these hiding events, when "command"
> is received, the menuitem doesn't have a parent node anymore.
I've looked into this a bit and wasn't able to find a solution.

Command events are fired when Cocoa calls -[NativeMenuItemTarget menuItemHit:] in nsMenuBarX.mm (which is the menu item's action handler).
The popuphiding and popuphidden events are sent when Cocoa calls -[MenuDelegate menuDidClose:] in nsMenuX.mm.

Unfortunately, Cocoa always calls menuDidClose before menuItemHit when a menu item is clicked. I've tried to work around this by using the NSMenuDidEndTrackingNotification notification instead of menuDidClose, but that notification also fires before menuItemHit, so that didn't work.

We could send the popuphiding/popuphidden events from an nsRunnable, I guess. I don't know if it's worth the effort.

I ended up fixing this in bug 1698997. Wow, I had no idea that I had filed a bug about this 7 years ago!

Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.