Discussion:
How to make my NSViewControllers participate in responder chain?
(too old to reply)
Rick Mann
2018-06-30 09:46:12 UTC
Permalink
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
***@latencyzero.com


_______________________________________________

Cocoa-dev mailing list (Cocoa-***@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/gegs%40ml-in.narkive.net

This email sent to ***@ml-in.narkive.net
Richard Charles
2018-06-30 14:10:43 UTC
Permalink
Post by Rick Mann
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 (Cocoa-***@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/gegs%40ml-in.narkive.net

This email sent to ***@ml-in.narkive.net

Continue reading on narkive:
Loading...