On 5 Jul 2018, at 6:44, Rick Mann wrote:

Annoying I have to have a first responder view just to allow even my Document to respond to menu commands.

Quoting the [documentation](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/EventOverview/EventArchitecture/EventArchitecture.html):

For document-based applications, the default responder chain for the main window consists of the following responders and delegates:

1. The main window’s first responder and the successive responder objects up the view hierarchy
2. The main window itself
3. The window's NSWindowController object (which inherits from NSResponder)
4. The main window’s delegate.
5. The NSDocument object (if different from the main window’s delegate)
6. The application object, NSApp
7. The application object's delegate
8. The application's document controller (an NSDocumentController object, which does not inherit from NSResponder)

As you can see, both the window’s delegate, application object’s delegate, and the `NSDocument` instance itself, is part of the responder chain, which is where you would implement your menu item actions.

Implementing action methods in the view hierarchy should only be used for view-specific actions such as `copy:` and `paste:` (which would depend on the first responder, i.e. ⌘C does different things depending on which view is the first responder, but e.g. ⌘S should always go to the document’s `saveDocument:` action).
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to