質問

In my Cocoa application on the application menu there is a menu item "Delete", which sends a delete: message to first responder. Now, I have the keyboard focus on a NSOutlineView, which is the first responder in this case. Short of subclassing NSOutlineView, is there any way to handle the delete: message being passed to it? Neither the NSOutlineViewDelegate nor the NSOutlineViewDataSource protocol seems to define anything interesting for handling those actions.

役に立ちましたか?

解決

The first responder is exactly that: The first responder. It will forward anything it isn't interested in to its next responder, and that may forward it in turn, and so on until the message reaches the application object.

So all you need to do to handle this message is be in the responder chain. A window controller is a good way to do it; it will be the window's next responder.

See “Event Architecture” in the Event-Handling Guide.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top