#nullable enable namespace Terminal.Gui; /// /// Provides a collection of s bound to s. /// /// /// /// public class KeyBindings : InputBindings { /// Initializes a new instance bound to . public KeyBindings (View? target) : base ((commands, key) => new (commands), new KeyEqualityComparer ()) { Target = target; } /// public override bool IsValid (Key eventArgs) { return eventArgs.IsValid; } /// /// /// Adds a new key combination that will trigger the commands in on the View /// specified by . /// /// /// If the key is already bound to a different array of s it will be rebound /// . /// /// /// /// /// The key to check. /// /// The View the commands will be invoked on. If , the key will be bound to /// . /// /// /// The command to invoked on the when is pressed. When /// multiple commands are provided,they will be applied in sequence. The bound strike will be /// consumed if any took effect. /// public void Add (Key key, View? target, params Command [] commands) { KeyBinding binding = new (commands, target); Add (key, binding); } /// /// The view that the are bound to. /// /// /// If the KeyBindings object is being used for Application.KeyBindings. /// public View? Target { get; init; } }