public readonly struct CommandHandlerThe handler a command id resolved to, and the two things a caller can do with it.
Remarks
A struct, because a persistently visible surface asks per item per frame. A toolbar of twenty buttons re-resolving on the tick is twenty of these; as a class that would be twenty allocations a frame for a question whose answer is usually "the same one as last time". Resolve hands one back by value and null costs nothing either.
It names what it was found on, which is what makes a diagnostic overlay — and a test — able to say which of two views answered rather than only that something did. Exactly one of Element and Responder is set: the walk reaches elements first and non-element responders afterwards, and a handler knows which leg it came off.
Fields and properties (7)
public string IdThe command id this answers to.
public UiElement? ElementThe element that declared it, or null when a non-element responder did.
public IResponder? ResponderThe responder that declared it, or null when an element did.
public bool CanExecuteWhether it can run right now.
public string? TitleWhat it should be called right now, or null if it does not rename itself.
public bool IsCheckableWhether this command is a toggle at all, without asking what it is set to.
public bool IsCheckedWhether a checkable command is currently on. false for one that is not checkable.
Methods (8)
public static CommandHandler For(string id, IResponder responder, Action execute, Func<bool>? canExecute = null, Func<string?>? title = null, Func<bool>? isChecked = null)Builds a handler for a responder that is not an element.
public void Run()Runs it, whether or not it said it could.
public bool Equals(CommandHandler other)Indicates whether the current object is equal to another object of the same type.
public override bool Equals(object? obj)Indicates whether this instance and a specified object are equal.
public override int GetHashCode()Returns the hash code for this instance.
public static bool operator ==(CommandHandler left, CommandHandler right)Whether two handlers are the same registration.
public static bool operator !=(CommandHandler left, CommandHandler right)Whether two handlers are different registrations.
public override string ToString()Returns the fully qualified type name of this instance.
Used by (16)
- ButtonBaseVixen.Ui.Controls
- CommandBindingTestsVixen.Ui.Controls.Tests
- CommandDispatcherVixen.Ui.Controls
- CommandRegistryVixen.Ui.Controls
- CommandResponderVixen.Ui
- CommandResponderTestsVixen.Ui.Tests
- CommandRouteVixen.Ui
- CommandRouteTestsVixen.Ui.Tests
- ControllerVixen.Ui.Tests
- CountingResponderVixen.Ui.Tests
- IResponderVixen.Ui
- UiElementVixen.Ui
- UndoCommandsTestsVixen.Ui.Tests
- CommandChainTestsVixen.Editor.Ui.Tests
- EditorApplicationVixen.Editor.App
- ToolbarPresenterVixen.Editor.Ui