Re: First Responder and menus
Re: First Responder and menus
- Subject: Re: First Responder and menus
- From: "Alan Smith" <email@hidden>
- Date: Wed, 5 Jul 2006 18:54:14 -0400
This is all well and good but it doesn't help. I know that the menu
item isn't connected to the Responder Chain otherwise it would be
enabled.
So, the question is: How do I add it to the Responder Chain?
In the TextEdit example on my hard disk I can't seem to figure out how
the "Make Rich Text" item works. It's connected to First Responder and
I've found that File's Owner's delegate is an instance of the
Controller class. The only problem is that there is no implementation
of makeRichText: in the Controller class. It's in the Document class
and Controller just imports that.
How do I connect a menu item to a class that may not be in the
MainMenu nib? If I make an instance of that class and put it in the
MainMenu and connect it that way, it will get the instances mixed up.
Thanks, Alan
On 7/5/06, Matt Neuburg <email@hidden> wrote:
On Wed, 5 Jul 2006 02:01:12 -0400, "Michael Ash" <email@hidden>
said:
>On 7/4/06, Matt Neuburg <email@hidden> wrote:
>> On Tue, 4 Jul 2006 08:52:12 -0400, "Alan Smith" <email@hidden>
>> said:
>>
>> >I'm trying to hook a menu item in one nib to an action of a controller
>> >in another nib. I spent this morning reading about First Responder and
>> >have thoroughly searched the internet. I found lots of articles but
>> >they all say the same thing: Add an action in the First Responder in
>> >the nib with the menu item and add an action to the controller. Well,
>> >I've done that and the menu item remains grayed out. I then tried
>> >making my controller a NSWindowController, that didn't help either.
>>
>> Here's a really great trick for these situations. Simply implement
>> validateMenuItem: in the same class where you hope to receive the action
>> message, and add some logging so you know whether it's being called. Now run
>> your app and attempt to choose your menu item. If validateMenuItem: isn't
>> called, your instance is not in the responder chain and you need to review
>> your understanding of the responder chain. m.
>
>validateMenuItem: won't get called unless the system has already
>determined that your object responds to the action
Sorry about that. My "trick" depended upon some rather specialized
conditions that don't always inhere. m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
_______________________________________________
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
--
// Quotes from yours truly -------------------------
"You don't forget, you just don't remember."
"Maturity resides in the mind."
"Silence is the Universe's greatest gift."
"Don't waste your life doing things others have already done."
_______________________________________________
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