Re: Updating NSMenu while it's open
Re: Updating NSMenu while it's open
- Subject: Re: Updating NSMenu while it's open
- From: Ken Thomases <email@hidden>
- Date: Fri, 20 Apr 2012 01:12:09 -0500
On Apr 18, 2012, at 3:14 PM, vinayak pai wrote:
> I have a NSMenu with dynamically added NSMenuItems. The NSMenu is not
> refreshing properly while it's kept open.
> The NSMenu update method is called in NSRunLoopCommonModes.
I think I've answer you in another forum, but you can simply call the appropriate methods of NSMenu and NSMenuItem to modify them.
For example, my company's application, CrossOver, populates a "Programs" menu by scanning the contents of a particular folder. The menu starts out with a single disabled "Loading…" item. In a background thread, the app scans the folder and builds a hierarchy of programs. When the scan is complete, it does a -performSelectorOnMainThread:… to install that hierarchy in the menu.
Since the scanning is occurring on a background thread, it is "spontaneous" from the point of view of the UI. If the Programs menu is pulled down when it completes, the menu will update itself. However, in doing some testing right now, I see that it only updates when some event occurs. Mouse movement is enough. However, if I pull down the menu and leave the mouse still, it will not update no matter how long I leave it. Then, when I move the mouse, poof, the menu updates. Testing done on Lion 10.7.3.
Regards,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden