1234567891011121314151617181920212223242526272829303132333435363738394041 |
- #nullable enable
- namespace Terminal.Gui;
- /// <summary>
- /// Provides context for a <see cref="Command"/> that is being invoked.
- /// </summary
- /// <remarks>
- /// <para>
- /// To define a <see cref="Command"/> that is invoked with context,
- /// use <see cref="View.AddCommand(Command,Func{CommandContext,Nullable{bool}})"/>
- /// </para>
- /// </remarks>
- public record struct CommandContext
- {
- /// <summary>
- /// Initializes a new instance of <see cref="CommandContext"/> with the specified <see cref="Command"/>,
- /// </summary>
- /// <param name="command"></param>
- /// <param name="key"></param>
- /// <param name="keyBinding"></param>
- public CommandContext (Command command, Key? key, KeyBinding? keyBinding = null)
- {
- Command = command;
- Key = key;
- KeyBinding = keyBinding;
- }
- /// <summary>
- /// The <see cref="Command"/> that is being invoked.
- /// </summary>
- public Command Command { get; set; }
- /// <summary>
- /// The <see cref="Key"/> that is being invoked. This is the key that was pressed to invoke the <see cref="Command"/>.
- /// </summary>
- public Key? Key { get; set; }
- /// <summary>
- /// The KeyBinding that was used to invoke the <see cref="Command"/>, if any.
- /// </summary>
- public KeyBinding? KeyBinding { get; set; }
- }
|