Re: NSPopUpButton from NSMenu...
Re: NSPopUpButton from NSMenu...
- Subject: Re: NSPopUpButton from NSMenu...
- From: Shaun Wexler <email@hidden>
- Date: Wed, 23 Apr 2003 06:15:16 -0700
On Wednesday, April 23, 2003, at 01:57 AM, Mike Engler wrote:
Is there a way to programatically determine the
NSPopUpButton that contains a NSMenu, given the NSMenu
object?
Do you "know of" all of your popup menus? If not, you will need to
build an array of them, either by walking the view heirarchies of all
known windows, or by some other method which fits your application's
requirements. Once you have all the popups, the rest is easy, as long
as the actual NSMenu object you are searching for actually is owned by
the popup. Otherwise, you'll also need to iterate each menu, comparing
items/titles.
- (NSPopUpButton *) firstPopupInArray:(NSArray *)allPopups
withMenu:(NSMenu *)menu
{
NSEnumerator *popupEnum = [allPopups objectEnumerator];
id popup;
while (popup = [popupEnum nextObject])
if ([popup isMemberOfClass:[NSPopUpButton class]] && [[popup menu]
isEqual:menu])
return (NSPopUpButton *)popup;
return nil;
}
I'd personally like to know of a way to share a single NSMenu object
between multiple popups, so that they all have the same items, etc, and
changing the master menu would update all the popup buttons it belongs
to. I had to write a handful of methods to manage this behavior...
--
Shaun Wexler
MacFOH
http://www.macfoh.com
_______________________________________________
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.