• 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: building a lazy NSMenu
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: building a lazy NSMenu


  • Subject: Re: building a lazy NSMenu
  • From: Peter Maurer <email@hidden>
  • Date: Fri, 30 Jan 2004 12:19:51 +0100

I'll like to build it only as the users traverses it. So when the menu is first shown I will just show the files listed in the root directory. And for the menu items that represent folders in the root directory i'll add empty submenus... and these submenus should not be populated until they are actually show.

There are basically two ways of doing this. If your app doesn't need to run on OS X versions prior to 10.3, you can use NSMenu's new delegate methods ("[NSMenu numberOfItemsInMenu:]", etc.).

If your app should not be restricted to 10.3, you will have to access the carbon menu that's behind your NSMenu. You can get its menu reference with "_NSGetCarbonMenu()". Then you'll have to install your own event handler for the "kEventMenuOpening" (< OS X 10.3, iirc) event or the "kEventMenuPopulate" (>= OS X 10.3, iirc) event, and populate the menu from within your event handler.

This second method works for all OS X versions whose NSMenus are based on carbon menus. I'm afraid I'm not sure when that started, however (Google will tell you...).

Peter Maurer.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >building a lazy NSMenu (From: Jesse Grosjean <email@hidden>)

  • Prev by Date: Playing sound effect in thread
  • Next by Date: Re: Problem with CircleView Example and NSLayoutManager angles...
  • Previous by thread: building a lazy NSMenu
  • Next by thread: Designing for multitudinous objects
  • Index(es):
    • Date
    • Thread