Table of Contents

Class Button

Namespace
Terminal.Gui
Assembly
Terminal.Gui.dll

Button is a View that provides an item that invokes an Action when activated by the user.

public class Button : View, IDisposable, ISupportInitializeNotification, ISupportInitialize
Inheritance
Button
Implements
Inherited Members

Remarks

Provides a button showing text invokes an Action when clicked on with a mouse or when the user presses SPACE, ENTER, or hotkey. The hotkey is the first letter or digit following the first underscore ('_') in the button text.

Use HotKeySpecifier to change the hotkey specifier from the default of ('_').

If no hotkey specifier is found, the first uppercase letter encountered will be used as the hotkey.

When the button is configured as the default (IsDefault) and the user presses the ENTER key, if no other View processes the KeyEvent, the Button's Action will be invoked.

Constructors

Button()

Initializes a new instance of Button using Computed layout.

Button(ustring, bool)

Initializes a new instance of Button using Computed layout.

Button(int, int, ustring)

Initializes a new instance of Button using Absolute layout, based on the given text

Button(int, int, ustring, bool)

Initializes a new instance of Button using Absolute layout, based on the given text.

Properties

HotKey

Gets or sets the HotKey defined for this view. A user pressing HotKey on the keyboard while this view has focus will cause the Clicked event to fire.

IsDefault

Gets or sets whether the Button is the default action to activate in a dialog.

Methods

MouseEvent(MouseEvent)

Method invoked when a mouse event is generated

OnClicked()

Virtual method to invoke the Clicked event.

OnEnter(View)

Method invoked when a view gets focus.

PositionCursor()

Positions the cursor in the right position based on the currently focused view in the chain.

ProcessColdKey(KeyEvent)

This method can be overwritten by views that want to provide accelerator functionality (Alt-key for example), but without interefering with normal ProcessKey behavior.

ProcessHotKey(KeyEvent)

This method can be overwritten by view that want to provide accelerator functionality (Alt-key for example).

ProcessKey(KeyEvent)

If the view is focused, gives the view a chance to process the keystroke.

UpdateTextFormatterText()

Can be overridden if the Text has different format than the default.

Events

Clicked

Clicked Action, raised when the user clicks the primary mouse button within the Bounds of this View or if the user presses the action key while this view is focused. (TODO: IsDefault)