Skip to content

A Cocoa view controller subclass that includes responder chain patching

License

Notifications You must be signed in to change notification settings

KosmicTask/XSViewController

Repository files navigation

XSViewController

A Cocoa view controller subclass that implements responder chain patching when used in conjunction with XSWindowController.

Also includes:

  • NSResponder+XSViewController : Responder chain category

This is a reboot of the original implementation (zip). The original functionality has been retained but the API has been updated.

Build Requirements

OS X 64 bit ARC.

Using XSViewController

Read the legacy articles below for guidance then read the header file notes.

Usage is a three step process:

  1. Instantiate an XSWindowController (or a subclass thereof).
  2. Add XSViewController children to the XSWindowController instance.
  3. Add further XSViewController children to XSViewControllerinstances.

As the XSViewController children are manipulated they will be added and removed from the responder chain as long as at least the topmost XSViewController instance in any given tree has an assigned window controller.

Note that this reboot modifies the default behaviour of the original implementation. The previous implementation's behaviour, as described in the legacy documents, can be recovered like so:

// Class configuration - disallow calling NSViewController's designated initialiser
[XSViewController setRaiseExceptionForDesignatedInitialiser:YES] 

XSWindowController *winController = [[MyXSWindowControllerSubclass alloc] init]; 

// Patch the responder chain from the window controller as opposed to the window
winController.responderChainPatchRoot = winController;

// Add controllers in descending order - that is starting with the root rather than the children
winController.addControllersToResponderChainInAscendingOrder = NO;

Using NSResponder+XSViewController

The various NSResponder category methods such as - xsv_actionResponderChainFromSelf return arrays of objects sorted in the order in which they occur in the responder chain. Both action and event responder chains can be requested.

The constructed responder chains should confirm to the chains discussed in the Apple Responder Chain info.

Legacy Articles

The original articles that accompanied the code are no longer available. However, archived versions of the articles are still accessible. These explain in some detail the reasoning that lies behind the code:

Authors

Created by Jonathan Dann and Cathy Shive on 14/04/2008.

Updated by Jonathan Mitchell on 20/11/2013.

About

A Cocoa view controller subclass that includes responder chain patching

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published