Re: building a lazy NSMenu
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.