Class Button
Button control
Implements
Namespace: FlaxEngine.GUI
Assembly: FlaxEngine.CSharp.dll
Syntax
[ActorToolbox("GUI")]
public class Button : Label, IComparable, IDrawable
Constructors
Button()
Button(Float2, Float2)
Initializes a new instance of the Button class.
Declaration
public Button(Float2 location, Float2 size)
Parameters
|
Float2
location
Position |
|
Float2
size
Size |
Button(Single, Single, Single, Single)
Initializes a new instance of the Button class.
Declaration
public Button(float x, float y, float width = 120F, float height = 24F)
Parameters
|
System.Single
x
Position X coordinate |
|
System.Single
y
Position Y coordinate |
|
System.Single
width
Width |
|
System.Single
height
Height |
Fields
_isPressed
True if button is being pressed (by mouse or touch).
Declaration
protected bool _isPressed
Field Value
|
System.Boolean
|
DefaultHeight
The default height for the buttons.
Declaration
public const float DefaultHeight = 24F
Field Value
|
System.Single
|
Properties
BackgroundColorHighlighted
Gets or sets the background color when button is highlighted.
Declaration
[EditorDisplay("Background Style", null)]
[EditorOrder(2001)]
public Color BackgroundColorHighlighted { get; set; }
Property Value
|
Color
|
BackgroundColorSelected
Gets or sets the background color when button is selected.
Declaration
[EditorDisplay("Background Style", null)]
[EditorOrder(2002)]
public Color BackgroundColorSelected { get; set; }
Property Value
|
Color
|
BorderColor
Gets or sets the color of the border.
Declaration
[EditorDisplay("Border Style", null)]
[EditorOrder(2012)]
public Color BorderColor { get; set; }
Property Value
|
Color
|
BorderColorHighlighted
Gets or sets the border color when button is highlighted.
Declaration
[EditorDisplay("Border Style", null)]
[EditorOrder(2013)]
public Color BorderColorHighlighted { get; set; }
Property Value
|
Color
|
BorderColorSelected
Gets or sets the border color when button is selected.
Declaration
[EditorDisplay("Border Style", null)]
[EditorOrder(2013)]
public Color BorderColorSelected { get; set; }
Property Value
|
Color
|
BorderThickness
Gets or sets the border thickness.
Declaration
[EditorDisplay("Border Style", null)]
[EditorOrder(2011)]
[Limit(0F, 3.40282347E+38F, 1F)]
public float BorderThickness { get; set; }
Property Value
|
System.Single
|
HasBorder
Gets or sets whether the button has a border.
Declaration
[EditorDisplay("Border Style", null)]
[EditorOrder(2010)]
[ExpandGroups]
public bool HasBorder { get; set; }
Property Value
|
System.Boolean
|
IsPressed
Gets a value indicating whether this button is being pressed (by mouse or touch).
Declaration
public bool IsPressed { get; }
Property Value
|
System.Boolean
|
TextMaterial
Gets or sets the custom material used to render the text. It must has domain set to GUI and have a public texture parameter named Font used to sample font atlas texture with font characters data. [Deprecated on 18.09.2024, expires on 18.09.2026]
Declaration
[Serialize]
[NoUndo]
public MaterialBase TextMaterial { get; set; }
Property Value
|
MaterialBase
|
Methods
ClearState()
Called to clear UI state. For example, removes mouse over state or drag and drop when control gets disabled or hidden (including hierarchy).
Declaration
public override void ClearState()
Overrides
DrawSelf()
OnClick()
Called when mouse or touch clicks the button.
Declaration
protected virtual void OnClick()
OnLostFocus()
When control losts input focus
Declaration
public override void OnLostFocus()
Overrides
OnMouseDoubleClick(Float2, MouseButton)
When mouse double clicks over control's area
Declaration
public override bool OnMouseDoubleClick(Float2 location, MouseButton button)
Parameters
|
Float2
location
Mouse location in Control Space |
|
MouseButton
button
Mouse buttons state (flags) |
Returns
|
System.Boolean
True if event has been handled, otherwise false |
Overrides
OnMouseDown(Float2, MouseButton)
When mouse goes down over control's area
Declaration
public override bool OnMouseDown(Float2 location, MouseButton button)
Parameters
|
Float2
location
Mouse location in Control Space |
|
MouseButton
button
Mouse buttons state (flags) |
Returns
|
System.Boolean
True if event has been handled, otherwise false |
Overrides
OnMouseEnter(Float2)
When mouse enters control's area
Declaration
public override void OnMouseEnter(Float2 location)
Parameters
|
Float2
location
Mouse location in Control Space |
Overrides
OnMouseLeave()
When mouse leaves control's area
Declaration
public override void OnMouseLeave()
Overrides
OnMouseUp(Float2, MouseButton)
When mouse goes up over control's area
Declaration
public override bool OnMouseUp(Float2 location, MouseButton button)
Parameters
|
Float2
location
Mouse location in Control Space |
|
MouseButton
button
Mouse buttons state (flags) |
Returns
|
System.Boolean
True if event has been handled, otherwise false |
Overrides
OnPressBegin()
Called when button starts to be pressed by the used (via mouse or touch).
Declaration
protected virtual void OnPressBegin()
OnPressEnd()
Called when button ends to be pressed by the used (via mouse or touch).
Declaration
protected virtual void OnPressEnd()
OnSubmit()
Generic user interaction event for a control used by UI navigation (eg. user submits on the currently focused control).
Declaration
public override void OnSubmit()
Overrides
OnTouchDown(Float2, Int32)
When touch enters control's area.
Declaration
public override bool OnTouchDown(Float2 location, int pointerId)
Parameters
|
Float2
location
Touch location in Control Space. |
|
System.Int32
pointerId
The touch pointer identifier. Stable for the whole touch gesture/interaction. |
Returns
|
System.Boolean
True if event has been handled, otherwise false. |
Overrides
OnTouchLeave()
When all touch leaves control's area
Declaration
public override void OnTouchLeave()
Overrides
OnTouchUp(Float2, Int32)
When touch goes up over control's area.
Declaration
public override bool OnTouchUp(Float2 location, int pointerId)
Parameters
|
Float2
location
Touch location in Control Space |
|
System.Int32
pointerId
The touch pointer identifier. Stable for the whole touch gesture/interaction. |
Returns
|
System.Boolean
True if event has been handled, otherwise false. |
Overrides
SetColors(Color)
Sets the button colors palette based on a given main color.
Declaration
public virtual void SetColors(Color color)
Parameters
|
Color
color
The main color. |
Events
ButtonClicked
Event fired when user clicks on the button.
Declaration
public event Action<Button> ButtonClicked
Event Type
|
System.Action<Button>
|
Clicked
Event fired when user clicks on the button.
Declaration
public event Action Clicked
Event Type
|
System.Action
|
HoverBegin
Event fired when users mouse enters the control.
Declaration
public event Action HoverBegin
Event Type
|
System.Action
|
HoverEnd
Event fired when users mouse leaves the control.
Declaration
public event Action HoverEnd
Event Type
|
System.Action
|