On Jan 6, 2013, at 6:17 AM, Arved von Brasch wrote:

> I have a modular single window application, where it has become necessary to 
> put control code into NSViewController subclasses.
> 
> I have googled extensively on this issue, and it seemed pretty easy.  The 
> solution I went with is here:
> http://www.cocoawithlove.com/2008/07/better-integration-for-nsviewcontroller.html
> 
> Inserting the ViewController just above the view it controls makes the most 
> amount of sense for my application.
> 
> I'm pretty sure I've done this correctly.  The controlled view of each Xib 
> file is an NSView subclass that inserts its controller into the responder 
> chain as described above.
> 
> I'm pretty sure this is done correctly, because if I query the responder 
> chain from one of its subviews, I can see that my ViewController is in the 
> list on the way to the window as expected in the responder chain.
> 
> My problem is that no actions I send to First Responder in the Xib files seem 
> to be called in the View Controller.  Buttons and Menu Items I connect to the 
> "First Responder" aren't called (and Menu Items aren't validated).
> 
> Is there something obvious I'm missing?  That's all that should be necessary 
> according to all the documentation I've seen.
> 
> Any help or hints to go about debugging would be greatly appreciated.

Just to be explicit, the custom NSView must also itself be in the responder 
chain--i.e. the first responder must the the view or one of its descendants. 
Also, you need to make sure that no other responder in the chain *below* the 
controller implements -validateMenu/UserInterfaceItem: and returns NO for the 
menu actions.

Other debugging aids are to trace through -setViewController: to make sure 
everything is wiring up correctly. I might also implement or put a breakpoint 
in the validate method in an object that I know is in the chain "naturally", 
such as the window controller. I would also double check the nextResponder 
value after-the-fact (a good place would be in the validate method I 
mentioned), to make sure it isn't being changed. I doubt this is the case but 
it doesn't hurt to check.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


_______________________________________________

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Reply via email to