Vixen
dd8b0a81
csharp
public interface IResponder

Something on the responder chain that is not an element.

Read the guide page for this →

Remarks

⚠ It was called ICommandResponder and answered command ids only. AppKit has one chain: the same NSResponder receives keyDown:, answers copy:, validates the menu item that sends it and supplies the undoManager. Vixen had three that did not meet, and the name recorded the narrowest of them. OnKey and UndoManager are the other two legs, defaulted in so that every existing implementation compiles unchanged and a responder that only answers verbs stays three lines long.

The part of the chain that is not the tree. AppKit's action chain does not stop at the view hierarchy: past the last view it consults the window, the window controller, the window's delegate, the document, NSApp and the application's delegate — and the guide is explicit that a delegate gets its chance "even though a delegate isn't formally in the responder chain". None of those are views. This is that, with the ceremony removed: an object that maps an id to a handler, consulted after the element walk has run out of parents.

⚠ It changes no rule, only the length of the walk. The first responder that answers still wins, and its CanExecute is still the only one asked — across the whole extended chain, exactly as inside the element walk. A responder further along that would also have answered is not consulted, and is not asked whether it could have.

⚠ No selector dispatch and no reflection (ADR-002). An implementation says which ids it answers by answering them; there is no respondsToSelector: here and none is possible under trimming.

CommandResponder is the implementation almost everything wants — a table a view-model or a document object fills in, owning no element. Implement this directly only when the lookup already exists somewhere else and mirroring it would be a second copy to keep in step; the editor's CommandRegistry is that case.

Fields and properties (1)

  • IUndoManager? UndoManager

    The undo manager this responder supplies to the chain, if it owns one.

Methods (2)

  • bool TryGetCommandHandler(string id, out CommandHandler handler)

    The handler this responder has for a command id, if it has one.

  • bool OnKey(KeyEvent args)

    A chance at a key event, at the position on the chain the responder was appended at.

Used by (10)

  • CommandBindingsVixen.Ui
  • CommandHandlerVixen.Ui
  • CommandRegistryVixen.Ui.Controls
  • CommandResponderVixen.Ui
  • CommandResponderTestsVixen.Ui.Tests
  • CommandRouteVixen.Ui
  • ControllerVixen.Ui.Tests
  • CountingResponderVixen.Ui.Tests
  • UiDocumentVixen.Ui
  • UiElementVixen.Ui