Class ButtonBase
Base class for creating a button type control.
Inherited Members
Namespace: SadConsole.UI.Controls
Assembly: SadConsole.dll
Syntax
[DataContract]
public abstract class ButtonBase : ControlBase
Constructors
ButtonBase()
Declaration
protected ButtonBase()
ButtonBase(int, int)
Creates a new button control.
Declaration
protected ButtonBase(int width, int height)
Parameters
Type | Name | Description |
---|---|---|
int | width | Width of the button. |
int | height | Height of the button. |
Fields
_textAlignment
The alignment of the SadConsole.UI.Controls.ButtonBase._text.
Declaration
protected HorizontalAlignment _textAlignment
Field Value
Type | Description |
---|---|
HorizontalAlignment |
Properties
AutoSize
Declaration
[DataMember]
public bool AutoSize { get; set; }
Property Value
Type | Description |
---|---|
bool |
Text
The text displayed on the control.
Declaration
[DataMember]
public string Text { get; set; }
Property Value
Type | Description |
---|---|
string |
TextAlignment
The alignment of the text, left, center, or right.
Declaration
[DataMember]
public HorizontalAlignment TextAlignment { get; set; }
Property Value
Type | Description |
---|---|
HorizontalAlignment |
Methods
InvokeClick(bool)
Simulates a mouse click on the button. Optionally, focuses the button prior to simulating the click.
Declaration
public void InvokeClick(bool focus = false)
Parameters
Type | Name | Description |
---|---|---|
bool | focus | When true, focuses the button before clicking. |
OnClick()
Raises the Click event.
Declaration
protected virtual void OnClick()
OnLeftMouseClicked(ControlMouseState)
Called when the left mouse button is clicked. Raises the MouseButtonClicked event and calls the DetermineState() method.
Declaration
protected override void OnLeftMouseClicked(ControlBase.ControlMouseState state)
Parameters
Type | Name | Description |
---|---|---|
ControlBase.ControlMouseState | state | The current mouse data |
Overrides
OnMouseExit(ControlMouseState)
Called when the mouse exits the area of the control. Raises the MouseExit event and calls the DetermineState() method.
Declaration
protected override void OnMouseExit(ControlBase.ControlMouseState state)
Parameters
Type | Name | Description |
---|---|---|
ControlBase.ControlMouseState | state | The current mouse data |
Overrides
OnMouseIn(ControlMouseState)
Called as the mouse moves around the control area. Raises the MouseMove event and calls the DetermineState() method.
Declaration
protected override void OnMouseIn(ControlBase.ControlMouseState state)
Parameters
Type | Name | Description |
---|---|---|
ControlBase.ControlMouseState | state | The current mouse data |
Overrides
ProcessKeyboard(Keyboard)
Detects if the SPACE or ENTER keys are pressed and calls the Click method.
Declaration
public override bool ProcessKeyboard(Keyboard info)
Parameters
Type | Name | Description |
---|---|---|
Keyboard | info |
Returns
Type | Description |
---|---|
bool |
Overrides
Events
Click
Raised when the button is clicked.
Declaration
public event EventHandler? Click
Event Type
Type | Description |
---|---|
EventHandler |