• 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: NSView - trouble setting next responder on 10.10 - works okay on 10.9
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSView - trouble setting next responder on 10.10 - works okay on 10.9


  • Subject: Re: NSView - trouble setting next responder on 10.10 - works okay on 10.9
  • From: Quincey Morris <email@hidden>
  • Date: Sat, 03 Oct 2015 10:43:06 -0700
  • Feedback-id: 167118m:167118agrif8a:167118sf-sXJ_rt6:SMTPCORP

On Oct 3, 2015, at 07:42 , Jonathan Mitchell <email@hidden> wrote:
>
> The responder chain is, as you know, very flexible.

I’m not accusing you of mistreating the responder chain, I’m accusing you of mistreating event handling. :)

Event handling is based on the idea of hierarchical containment, so that a view controller is expected to handle only actions from its own view’s sub-hierarchy. You’re trying to route actions from elsewhere into the view controller “container”. (iOS already has this concept of view controller containment, that parallels the view containment hierarchy.)

I suggest you consider breaking your view controllers apart into two objects. One, a “view responder” would be a NSResponder subclass that you insert into the responder chain just below the window controller. The other, an actual NSViewController subclass, would be inserted into the responder chain wherever the frameworks want, or possibly not at all pre-10.10.

Ideally, all of the business logic would be moved from its current home in the view controller to the view responder, including the action messages. All that’d be left in the view controller would be the outlets (if any), and the viewDidLoad logic necessary to prepare the view itself (and also to create the view responder, and insert it in the responder chain). Alternatively, you could keep all the local-to-view logic in the view controller, and put only the trans-view logic in the view responder, but this may get a bit messy if both share the same custom data structures.

This shouldn’t involve much change to existing code. Each object in the pair would have a reference to the other. Except for the responder chain setup, the main difference in code would be that your view responder would reference outlets as self.viewController.myOutlet, instead of self.myOutlet. If you have view controller bindings in the NIBs, you can change them to bind through to the view responder, or (if there are too many to change) define derived properties in the view controller that mirror the real properties in the view responder.

_______________________________________________

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: NSView - trouble setting next responder on 10.10 - works okay on 10.9
      • From: Jonathan Mitchell <email@hidden>
References: 
 >Re: NSView - trouble setting next responder on 10.10 - works okay on 10.9 (From: Conrad Shultz <email@hidden>)
 >Re: NSView - trouble setting next responder on 10.10 - works okay on 10.9 (From: Jonathan Mitchell <email@hidden>)
 >Re: NSView - trouble setting next responder on 10.10 - works okay on 10.9 (From: Quincey Morris <email@hidden>)
 >Re: NSView - trouble setting next responder on 10.10 - works okay on 10.9 (From: Jonathan Mitchell <email@hidden>)

  • Prev by Date: Re: NSView - trouble setting next responder on 10.10 - works okay on 10.9
  • Next by Date: Value of type '[AnyObject]!' has no member 'Generator'
  • Previous by thread: Re: NSView - trouble setting next responder on 10.10 - works okay on 10.9
  • Next by thread: Re: NSView - trouble setting next responder on 10.10 - works okay on 10.9
  • Index(es):
    • Date
    • Thread