• 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: NSPopUpButton from NSMenu...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.
References: 
 >NSPopUpButton from NSMenu... (From: Mike Engler <email@hidden>)

  • Prev by Date: Re: Getting a message when directory content changes
  • Next by Date: Re: Getting a message when directory content changes
  • Previous by thread: NSPopUpButton from NSMenu...
  • Next by thread: autolauched application to reboot or startup
  • Index(es):
    • Date
    • Thread