> > I have objects stored in two different nibs that I'd like to
> > communicate to each other. So as I understand it, I need there to be
[quoted text clipped - 5 lines]
> l/ActionMessages/Concepts/TargetsAndActions.html if you set the action to
> nil, the [message will be delivered] to the first responder.
That should read 'send the action to nil', so the _target_ should be set
to nil ;-)
@Wizumwalt:
There are several ways to connect actions.
- To the file's owner: set its class in IB and you can control drag a
connection from your control to any custom actions the file's owner
defines.
- 'Nil targeted actions' / First responder: in the IB inspector for the
first responder you can add your own action methods. The receiver will
be determined at runtime, like the document above outlines. This is
useful if more than one object in your nib could be the target of your
action (f.i. 'copy:') or if you want to send an action on an object that
is in the responder chain, but to which you have no reference in your
nib file.
- Refer to a singleton object outside the nib directly:
[toolbarItem setTarget:[NSApp delegate]];
patrick
David Phillip Oster - 25 May 2007 15:03 GMT
> > > I have objects stored in two different nibs that I'd like to
> > > communicate to each other. So as I understand it, I need there to be
[quoted text clipped - 8 lines]
> That should read 'send the action to nil', so the _target_ should be set
> to nil ;-)
Thanks for the correction. Yes, of course I was trying to say: set the
target to nil, and the action is sent up the responder chain.
> @Wizumwalt:
> There are several ways to connect actions.
[quoted text clipped - 15 lines]
>
> patrick
Wizumwalt@gmail.com - 28 May 2007 21:41 GMT
> - 'Nil targeted actions' / First responder: in the IB inspector for the
> first responder you can add your own action methods. The receiver will
[quoted text clipped - 3 lines]
> is in the responder chain, but to which you have no reference in your
> nib file.
I'm trying to do this option here and I've been looking at this
howto ... http://www.cocoadev.com/index.pl?MenusAndDocuments ... I'm
trying to get a menu item talk to an action of a controller that is in
a separate nib file.
So I clicked on the first responder icon and added the action to my
main menu nib.
Then I connected the menu items to the first responder of the menu nib
and made the connections there. I have the action methods in a
controller which is in the MyDocument.nib, but when I run this, things
still aren't working.
I'm not sure what I'm doing wrong.
David Phillip Oster - 29 May 2007 01:47 GMT
> Then I connected the menu items to the first responder of the menu nib
> and made the connections there. I have the action methods in a
> controller which is in the MyDocument.nib, but when I run this, things
> still aren't working.
BY default, controllers aren't subclasses of NSResponder and aren't in
the responder chain. See: http://www.borkware.com/quickies/single?id=214
Michael Ash - 29 May 2007 04:21 GMT
>> Then I connected the menu items to the first responder of the menu nib
>> and made the connections there. I have the action methods in a
[quoted text clipped - 3 lines]
> BY default, controllers aren't subclasses of NSResponder and aren't in
> the responder chain. See: http://www.borkware.com/quickies/single?id=214
A much easier, although somewhat more limited, approach is to simply make
your controller be the delegate of your NSWindow instance. As the delegate
does not actually become part of the responder chain there is no need to
subclass NSResponder and there's no need to manually insert anything, but
you still get to handle any action messages that weren't handled by
anything in the window.
For more information on what gets sent where, see:
http://developer.apple.com/documentation/Cocoa/Conceptual/EventOverview/EventArc
hitecture/chapter_2_section_6.html

Signature
Michael Ash
Rogue Amoeba Software