• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSViewController in the responder chain
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSViewController in the responder chain


  • Subject: Re: NSViewController in the responder chain
  • From: Keary Suska <email@hidden>
  • Date: Sun, 06 Jan 2013 09:06:27 -0700

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 (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSViewController in the responder chain
      • From: Andy Lee <email@hidden>
References: 
 >NSViewController in the responder chain (From: Arved von Brasch <email@hidden>)

  • Prev by Date: NSViewController in the responder chain
  • Next by Date: Re: NSViewController in the responder chain
  • Previous by thread: NSViewController in the responder chain
  • Next by thread: Re: NSViewController in the responder chain
  • Index(es):
    • Date
    • Thread