Table of Contents

Class Shortcut

Namespace
Terminal.Gui
Assembly
Terminal.Gui.dll

Displays a command, help text, and a key binding. When the key specified by Key is pressed, the command will be invoked. Useful for displaying a command in Bar such as a menu, toolbar, or status bar.

public class Shortcut : View, IDisposable, ISupportInitializeNotification, ISupportInitialize, IOrientation, IDesignable
Inheritance
Shortcut
Implements
Inherited Members

Remarks

The following user actions will invoke the Accept, causing the Accepting event to be fired: - Clicking on the Shortcut. - Pressing the key specified by Key. - Pressing the HotKey specified by CommandView.

If BindKeyToApplication is true, Key will invoke Accept regardless of what View has focus, enabling an application-wide keyboard shortcut.

By default, a Shortcut displays the command text on the left side, the help text in the middle, and the key binding on the right side. Set AlignmentModes to EndToStart to reverse the order.

The command text can be set by setting the CommandView's Text property or by setting Title.

The help text can be set by setting the HelpText property or by setting Text.

The key text is set by setting the Key property. If the Key is Empty, the Key text is not displayed.

Constructors

Shortcut()

Creates a new instance of Shortcut.

Shortcut(Key, string?, Action?, string?)

Creates a new instance of Shortcut.

Shortcut(View, Command, string, string?)

Creates a new instance of Shortcut, binding it to targetView and command. The Key targetView has bound to command will be used as Key.

Properties

Action

Gets or sets the action to be invoked when the shortcut key is pressed or the shortcut is clicked on with the mouse.

AlignmentModes

Gets or sets the AlignmentModes for this Shortcut.

BindKeyToApplication

Gets or sets whether Key is bound to Command via HotKeyBindings or KeyBindings.

ColorScheme

The color scheme for this view, if it is not defined, it returns the SuperView's color scheme.

Command

Gets the Command that will be invoked on TargetView when the Shortcut is activated.

CommandView

Gets or sets the View that displays the command text and hotkey.

HelpText

Gets or sets the help text displayed in the middle of the Shortcut.

HelpView

The subview that displays the help text for the command. Internal for unit testing.

Key

Gets or sets the Key that will be bound to the Accept command.

KeyView

Gets the subview that displays the key. Internal for unit testing.

MinimumKeyTextSize

Gets or sets the minimum size of the key text. Useful for aligning the key text with other Shortcuts.

Orientation

Gets or sets the Orientation for this Bar. The default is Horizontal.

TargetView

Gets the target View that the Command will be invoked on.

Text

Gets or sets the help text displayed in the middle of the Shortcut. Identical in function to HelpText .

Methods

Dispose(bool)

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

EnableForDesign()

Causes the View to enable design-time mode. This typically means that the view will load demo data and be configured to allow for design-time manipulation.

OnHasFocusChanged(bool, View?, View?)

Invoked after HasFocus has changed. This method is called before the HasFocusChanged event is raised.

OnHighlight(CancelEventArgs<HighlightStyle>)

Called when the view is to be highlighted. The HighlightStyle passed in the event indicates the highlight style that will be applied. The view can modify the highlight style by setting the NewValue property.

OnOrientationChanged(Orientation)

Called when Orientation has changed.

Events

OrientationChanged

Raised when Orientation has changed.

OrientationChanging

Raised when Orientation is changing. Can be cancelled.