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

NEW
Unassigned

Status

()

Core
Widget: Cocoa
4 years ago
4 years ago

People

(Reporter: mstange, Unassigned)

Tracking

Trunk
All
Mac OS X
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

4 years ago
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.
(Reporter)

Comment 1

4 years ago
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.
You need to log in before you can comment on or make changes to this bug.