Re: How to make my NSViewControllers participate in responder chain?
Re: How to make my NSViewControllers participate in responder chain?
- Subject: Re: How to make my NSViewControllers participate in responder chain?
- From: Richard Charles <email@hidden>
- Date: Sat, 30 Jun 2018 08:10:43 -0600
> On Jun 30, 2018, at 3:46 AM, Rick Mann <email@hidden> wrote:
>
> I have a complex view hierarchy with a lot of controllers. I'd like to
> provide menu commands that the various controllers can respond to, but I have
> a couple of problems:
>
> 1) I can't seem to get any of my view controllers (even the window's root
> view controller) to participate, even if I override acceptsFirstResponder to
> return true.
> 2) What happens when I have sibling view controllers (e.g. in a split view
> controller)? I'd like all of them to participate, if they can.
>
> I can, of course, push all that stuff up to the root view controller, but
> that makes me do things like subclass NSSplitViewController.
>
> The whole thing seems cumbersome, at best. What am I missing?
>
> Thanks,
>
> --
> Rick Mann
I have an app with lots of views and a ton of custom controllers. If one of the
controllers is not in the responder chain but needs to be this is what I do.
@property (readonly, retain) MyResponder *responder;
// During initialization of my view which is already in the responder chain
// insert custom object into the responder chain. Refer to Cocoa Event
// Handling Guide, Event Architecture, The Responder Chain.
MyResponder *customObject = _responder;
NSResponder *nextResponder = self.nextResponder;
[self setNextResponder:customObject];
[customObject setNextResponder:nextResponder];
--Richard Charles
_______________________________________________
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