Thanks Quincey,

Passing in a reference to the document did the trick.  But I'm still confused 
as 
to why the 2d Nib isn't in the responder chain.  The docs say that the 
responder 
chain would start at the key window; proceed to the main window; and then thru 
MyDocument, NSApplication, etc.  Wouldn't the second window be a key window and 
the first one the main window?  The NSWindowController for nib #2 was declared 
in MyDocument.h w/@class . . . , and called by MyDocument.m.

Jason 


> Message:  12
> Date: Tue, 3 Aug 2010 13:34:57 -0700
> From: Quincey Morris <quinceymor...@earthlink.net>
> Subject:  Re: Need help understanding first responder and multiple nibs
> To: cocoa-dev  <cocoa-dev@lists.apple.com>
> Message-ID:  <c781f232-43cf-4ea8-9bcb-ac93315da...@earthlink.net>
> Content-Type:  text/plain; charset=us-ascii
> 
> 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