ButtonBase Class
Definition
Section titled “Definition”Base class for creating a button type control.
[DataContract]public abstract class ButtonBase : ControlBaseInheritance object → ControlBase
Constructors
Section titled “Constructors”ButtonBase(int, int)
Section titled “ButtonBase(int, int)”Creates a new button control.
protected ButtonBase(int width, int height)Parameters
Section titled “Parameters”width int
Width of the button.
height int
Height of the button.
ButtonBase()
Section titled “ButtonBase()”Creates a new button control with AutoSize set to true.
protected ButtonBase()Fields
Section titled “Fields”_textAlignment
Section titled “_textAlignment”The alignment of the SadConsole.UI.Controls.ButtonBase._text.
protected HorizontalAlignment _textAlignmentProperties
Section titled “Properties”The text displayed on the control.
[DataMember]public string Text { get; set; }AutoSize
Section titled “AutoSize”When true, automatically resizes the surface to fit the Text.
[DataMember]public bool AutoSize { get; set; }TextAlignment
Section titled “TextAlignment”The alignment of the text, left, center, or right.
[DataMember]public HorizontalAlignment TextAlignment { get; set; }Methods
Section titled “Methods”OnClick()
Section titled “OnClick()”Raises the Click event.
protected virtual void OnClick()InvokeClick(bool)
Section titled “InvokeClick(bool)”Simulates a mouse click on the button. Optionally, focuses the button prior to simulating the click.
public void InvokeClick(bool focus = false)Parameters
Section titled “Parameters”focus bool
When true, focuses the button before clicking.
ProcessKeyboard(Keyboard)
Section titled “ProcessKeyboard(Keyboard)”Detects if the SPACE or ENTER keys are pressed and calls the Click method.
public override bool ProcessKeyboard(Keyboard info)Parameters
Section titled “Parameters”info Keyboard
Returns
Section titled “Returns”OnMouseIn(ControlMouseState)
Section titled “OnMouseIn(ControlMouseState)”Called as the mouse moves around the control area. Raises the MouseMove event and calls the DetermineState() method.
protected override void OnMouseIn(ControlBase.ControlMouseState state)Parameters
Section titled “Parameters”state ControlBase.ControlMouseState
The current mouse data
OnLeftMouseClicked(ControlMouseState)
Section titled “OnLeftMouseClicked(ControlMouseState)”Called when the left mouse button is clicked. Raises the MouseButtonClicked event and calls the DetermineState() method.
protected override void OnLeftMouseClicked(ControlBase.ControlMouseState state)Parameters
Section titled “Parameters”state ControlBase.ControlMouseState
The current mouse data
OnMouseExit(ControlMouseState)
Section titled “OnMouseExit(ControlMouseState)”Called when the mouse exits the area of the control. Raises the MouseExit event and calls the DetermineState() method.
protected override void OnMouseExit(ControlBase.ControlMouseState state)Parameters
Section titled “Parameters”state ControlBase.ControlMouseState
The current mouse data
Events
Section titled “Events”Raised when the button is clicked.
public event EventHandler? Click