Re: Getting a reference to an NSMenuItem from another nib?
Re: Getting a reference to an NSMenuItem from another nib?
- Subject: Re: Getting a reference to an NSMenuItem from another nib?
- From: Andy Lee <email@hidden>
- Date: Tue, 14 Jun 2005 12:16:05 -0400
Setting design philosophy aside -- to solve the specific problem of
making menu items globally accessible, I would make a class that has
a singleton instance with outlets that you can connect to the various
menu items. Instantiate the class in IB and make the connections.
Or, subclass NSApplication, add outlets for menu items, and make that
subclass the File's Owner of MainMenu.nib. This way the menu items
become globally accessible either by way of [YourClass
singletonInstance] or by way of NSApp. You still can't make
connections to the menu items in multiple nibs, but you can send
messages directly to the menu items anywhere in your code, as you
wanted.
Note that this doesn't address the enabling and disabling of toolbar
items, which typically parallel menu items. In my own code I glommed
toolbar and menu validation into one -validateItem: method, which I
call from -validateMenuItem: and -validateToolbarItem:.
--Andy
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden