• 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: Dynamically populate a popup menu
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dynamically populate a popup menu


  • Subject: Re: Dynamically populate a popup menu
  • From: Peter N Lewis <email@hidden>
  • Date: Thu, 18 Feb 2010 10:38:47 +0800

On 17/02/2010, at 15:53 , Graham Cox wrote:
> On 17/02/2010, at 6:49 PM, Peter N Lewis wrote:
>
>> Is there any way to dynamically populate a popup menu on the fly (as it is exposed)?
>
> Look into the NSMenuDelegate protocol. It has methods to do what you want.

Yes, that looks like it will do what I need.  Hopefully the code will be fast enough to just use

- (void)menuNeedsUpdate:(NSMenu *)menu

otherwise I'll have to do a bit more work to get

- (NSInteger)numberOfItemsInMenu:(NSMenu *)menu
- (BOOL)menu:(NSMenu *)menu updateItem:(NSMenuItem *)item atIndex:(NSInteger)index shouldCancel:(BOOL)shouldCancel

working.

And I did know about NSPopUpButtonWillPopUpNotification, and indeed that was what I was using, but unfortunately it was taking about a minute to populate the menu, and therein lies the problem.

The menu is only about three or four levels deep in the normal case, and a menu selection is definitely the right UI for this use case, not a browser or some other mechanism.  About the only other good UI would be a big custom UI designed specifically for this use, and that's more work than I want for little or no gain in usability.

Thanks for the comments!
    Peter.

--
     Keyboard Maestro 4.0.2 now released!  Brand new interface!

Keyboard Maestro <http://www.keyboardmaestro.com/> Macros for your Mac
<http://www.stairways.com/>           <http://download.stairways.com/>










_______________________________________________

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

References: 
 >Dynamically populate a popup menu (From: Peter N Lewis <email@hidden>)
 >Re: Dynamically populate a popup menu (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: alternative to NSMatrix due to cell size restriction
  • Next by Date: Re: The 64 pixels width limit on Windows
  • Previous by thread: Re: Dynamically populate a popup menu
  • Next by thread: Re: Dynamically populate a popup menu
  • Index(es):
    • Date
    • Thread