• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Updating NSMenu while it's open
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Updating NSMenu while it's open
      • From: vinayak pai <email@hidden>
References: 
 >Updating NSMenu while it's open (From: vinayak pai <email@hidden>)

  • Prev by Date: Re: Updating NSMenu while it's open
  • Next by Date: Displaying another page/view on button click
  • Previous by thread: Re: Updating NSMenu while it's open
  • Next by thread: Re: Updating NSMenu while it's open
  • Index(es):
    • Date
    • Thread