Table of Contents

Struct CommandBinding

Namespace
Terminal.Gui.Input
Assembly
Terminal.Gui.dll

A generic command binding used for programmatic command invocations or when a specific binding type is not needed.

public readonly struct CommandBinding : ICommandBinding, IEquatable<CommandBinding>
Implements
Inherited Members

Remarks

Use CommandBinding when invoking commands programmatically via InvokeCommand(Command) or when a binding is needed but is not associated with a specific key or mouse event.

Source is a weak reference to the View that called InvokeCommand(Command). If null the CommandBinding instance was created dynamically (not from a mouse or keyboard binding).

Pattern match on binding types to discriminate between input sources:

<pre><code class="lang-csharp">if (ctx.Binding is KeyBinding kb) { /* key input */ }

else if (ctx.Binding is MouseBinding mb) { /* mouse input / } else if (ctx.Binding is CommandBinding ib) { / programmatic */ }

Constructors

CommandBinding(Command[], View?, object?)

Initializes a new instance.

Properties

Commands

Gets or sets the commands this command binding will invoke.

Data

Arbitrary context that can be associated with this command binding.

Source

Gets the View that registered the binding as a weak reference.

Methods

Equals(object)
Equals(CommandBinding)
GetHashCode()
ToString()

Operators

operator ==(CommandBinding, CommandBinding)
operator !=(CommandBinding, CommandBinding)

See Also