Show / Hide Table of Contents

Class ButtonBase

Base class for creating a button type control.

Inheritance
object
ControlBase
ButtonBase
Button
Button3d
ButtonBox
ToggleButtonBase
Inherited Members
ControlBase.MouseState_IsMouseOver
ControlBase.MouseState_EnteredWithButtonDown
ControlBase.MouseState_IsMouseLeftDown
ControlBase.MouseState_IsMouseRightDown
ControlBase.OnUnfocused()
ControlBase.OnFocused()
ControlBase.OnIsDirtyChanged()
ControlBase.ProcessMouse(MouseScreenObjectState)
ControlBase.LostMouse(MouseScreenObjectState)
ControlBase.OnParentChanged()
ControlBase.OnPositionChanged()
ControlBase.PlaceRelativeTo(ControlBase, Direction.Types, int)
ControlBase.DetermineState()
ControlBase.OnStateChanged(ControlStates, ControlStates)
ControlBase.OnSurfaceChanged(ICellSurface, ICellSurface)
ControlBase.FindThemeFont()
ControlBase.FindThemeColors()
ControlBase.SetThemeColors(Colors)
ControlBase.HasThemeColors()
ControlBase.Resize(int, int)
ControlBase.OnResized()
ControlBase.CreateControlSurface()
ControlBase.RefreshThemeStateColors(Colors)
ControlBase.OnMouseEnter(ControlBase.ControlMouseState)
ControlBase.OnRightMouseClicked(ControlBase.ControlMouseState)
ControlBase.UpdateAndRedraw(TimeSpan)
ControlBase.ThemeState
ControlBase.UseKeyboard
ControlBase.UseMouse
ControlBase.CanFocus
ControlBase.CanResize
ControlBase.AlternateFont
ControlBase.Surface
ControlBase.MouseArea
ControlBase.IsMouseButtonStateClean
ControlBase.Position
ControlBase.AbsolutePosition
ControlBase.IsVisible
ControlBase.Tag
ControlBase.TabStop
ControlBase.TabIndex
ControlBase.IsDirty
ControlBase.Name
ControlBase.FocusOnMouseClick
ControlBase.Width
ControlBase.Height
ControlBase.IsFocused
ControlBase.IsEnabled
ControlBase.Bounds
ControlBase.Parent
ControlBase.State
ControlBase.IsDirtyChanged
ControlBase.Focused
ControlBase.Unfocused
ControlBase.PositionChanged
ControlBase.MouseEnter
ControlBase.MouseExit
ControlBase.MouseMove
ControlBase.MouseButtonClicked
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: SadConsole.UI.Controls
Assembly: SadConsole.dll
Syntax
[DataContract]
public abstract class ButtonBase : ControlBase

Constructors

ButtonBase()

Creates a new button control with AutoSize set to true.

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

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

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
ControlBase.OnLeftMouseClicked(ControlBase.ControlMouseState)

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
ControlBase.OnMouseExit(ControlBase.ControlMouseState)

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
ControlBase.OnMouseIn(ControlBase.ControlMouseState)

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
ControlBase.ProcessKeyboard(Keyboard)

Events

Click

Raised when the button is clicked.

Declaration
public event EventHandler? Click
Event Type
Type Description
EventHandler

Extension Methods

ExtensionsSystem.GetDebuggerDisplayValue(object)
In this article

Back to top

Back to top Generated by DocFX