AFAIK NSMenu has a delegate method that gets called just before the
menu is shown. Implementing "menuNeedsUpdate_" in an NSMenu delegate
should do the trick, Apple's documentation for this method:
Called when a menu is about to be displayed at the start of a tracking
session so the delegate can modify the menu.
- (void)menuNeedsUpdate:(NSMenu *)menu
Parametersmenu
The menu object that is about to be displayed.
Discussion
You can change the menu by adding, removing or modifying menu items.
Be sure to set the proper enable state for any new menu items. If
populating the menu will take a long time,
implementnumberOfItemsInMenu: and
menu:updateItem:atIndex:shouldCancel: instead.
Ronald
On 9 Apr, 2009, at 10:41, Greg Ewing wrote:
> Anyone have any ideas how I can detect a mouse down
> event in the menu bar?
>
> I need this in PyGUI so I can set up the menus before
> they get pulled down.
>
> I've tried overriding sendEvent_() in NApplication,
> but mouse events in the menu bar seem to get
> swallowed before making it that far.
>
> So far I've been using a strange system-defined event
> that 10.4 produces when you click on the menu bar,
> but I'm told that this event no longer occurs in
> 10.5, so I need to find another way.
>
> --
> Greg
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by:
> High Quality Requirements in a Collaborative Environment.
> Download a free trial of Rational Requirements Composer Now!
> http://p.sf.net/sfu/www-ibm-com
> _______________________________________________
> Pyobjc-dev mailing list
> Pyo...@li...
> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev
|