On Aug 3, 2010, at 12:10, Jason Bruce wrote:

> I've set up a test project in order to understand how first responder works 
> across multiple nibs in a document-based application.  In my application, 
> MyDocument has a window with a text field and a single button on it which, 
> when 
> clicked, loads a second nib file which has only a window with a button on it. 
> File's owner on the second nib file is a sub-class of NSWindowController.  
> I've 
> connected the button on the second nib file window to that nib file's first 
> responder proxy object, and have added a method in the first responder proxy 
> object named "logClick:".  I have implemented logClick: in MyDocument, which 
> will do nothing but call NSLog(@"logClick called").  The intention is to have 
> the button on the second window call up the responder chain and be handled by 
> MyDocument -- but this isn't working.  This works if I connect a menu item to 
> first responder in the main menu nib which calls logClick:, but not when I 
> connect it to a button in a separate nib.  Can someone explain where my 
> misunderstanding is on this.  I've read the docs over and over and still 
> can't 
> figure it out.

It sounds like the window controller for nib#2 is just a free-standing object. 
In that case, the document won't be in the responder chain for events starting 
at nib#2's window, since there's no association between that window controller 
and the document.

The solution is to implement 'logClick:' (or whatever your action method really 
is) in the nib#2 window controller, and have that method invoke the NSDocument 
subclass's version of it. Of course, that means you have to pass the NSDocument 
pointer to the window controller when you create it.

Note that there's no real relationship between "the" responder chain and nib 
files. Your problem is an issue of *which* responder chain is handling events, 
and that depends solely on which window receives them, regardless of the nib 
file the window came from.


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to