Skip to content

ButtonBase Class

Base class for creating a button type control.

C#
[DataContract]
public abstract class ButtonBase : ControlBase

Inheritance objectControlBase

Creates a new button control.

C#
protected ButtonBase(int width, int height)

width int
Width of the button.

height int
Height of the button.

Creates a new button control with AutoSize set to true.

C#
protected ButtonBase()

The alignment of the SadConsole.UI.Controls.ButtonBase._text.

C#
protected HorizontalAlignment _textAlignment

The text displayed on the control.

C#
[DataMember]
public string Text { get; set; }

When true, automatically resizes the surface to fit the Text.

C#
[DataMember]
public bool AutoSize { get; set; }

The alignment of the text, left, center, or right.

C#
[DataMember]
public HorizontalAlignment TextAlignment { get; set; }

Raises the Click event.

C#
protected virtual void OnClick()

Simulates a mouse click on the button. Optionally, focuses the button prior to simulating the click.

C#
public void InvokeClick(bool focus = false)

focus bool
When true, focuses the button before clicking.

Detects if the SPACE or ENTER keys are pressed and calls the Click method.

C#
public override bool ProcessKeyboard(Keyboard info)

info Keyboard

bool

Called as the mouse moves around the control area. Raises the MouseMove event and calls the DetermineState() method.

C#
protected override void OnMouseIn(ControlBase.ControlMouseState state)

state ControlBase.ControlMouseState
The current mouse data

Called when the left mouse button is clicked. Raises the MouseButtonClicked event and calls the DetermineState() method.

C#
protected override void OnLeftMouseClicked(ControlBase.ControlMouseState state)

state ControlBase.ControlMouseState
The current mouse data

Called when the mouse exits the area of the control. Raises the MouseExit event and calls the DetermineState() method.

C#
protected override void OnMouseExit(ControlBase.ControlMouseState state)

state ControlBase.ControlMouseState
The current mouse data

Raised when the button is clicked.

C#
public event EventHandler? Click

EventHandler