Search Results for

    Show / Hide Table of Contents

    Class Button

    Button control

    Inheritance
    System.Object
    Control
    ContainerControl
    Label
    Button
    Implements
    System.IComparable
    IDrawable
    Inherited Members
    Label._text
    Label._font
    Label.PerformLayoutBeforeChildren()
    Label.Text
    Label.CaseOption
    Label.Bold
    Label.Italic
    Label.TextColor
    Label.TextColorHighlighted
    Label.HorizontalAlignment
    Label.VerticalAlignment
    Label.Wrapping
    Label.BaseLinesGapScale
    Label.Font
    Label.Material
    Label.Margin
    Label.ClipText
    Label.AutoWidth
    Label.AutoHeight
    Label.AutoFitText
    Label.AutoFitTextRange
    ContainerControl._children
    ContainerControl._containsFocus
    ContainerControl._isLayoutLocked
    ContainerControl.LockChildrenRecursive()
    ContainerControl.UnlockChildrenRecursive()
    ContainerControl.RemoveChildren()
    ContainerControl.DisposeChildren()
    ContainerControl.AddChild<T>()
    ContainerControl.AddChild<T>(T)
    ContainerControl.RemoveChild(Control)
    ContainerControl.GetChild(Int32)
    ContainerControl.GetChild<T>()
    ContainerControl.GetChildIndex(Control)
    ContainerControl.GetChildIndexAt(Float2)
    ContainerControl.GetChildAt(Float2)
    ContainerControl.GetChildAt(Float2, Func<Control, Boolean>)
    ContainerControl.GetChildAtRecursive(Float2)
    ContainerControl.GetClientArea()
    ContainerControl.SortChildren()
    ContainerControl.SortChildrenRecursive()
    ContainerControl.OnChildResized(Control)
    ContainerControl.OnChildrenChanged()
    ContainerControl.GetDesireClientArea(Rectangle)
    ContainerControl.IntersectsChildContent(Control, Float2, Float2)
    ContainerControl.OnNavigate(NavDirection, Float2, Control, List<Control>)
    ContainerControl.CanNavigateChild(Control)
    ContainerControl.NavigationWrap(NavDirection, Float2, List<Control>, Float2)
    ContainerControl.UpdateContainsFocus()
    ContainerControl.UpdateChildrenBounds()
    ContainerControl.PerformLayoutAfterChildren()
    ContainerControl.OnDestroy()
    ContainerControl.Update(Single)
    ContainerControl.Draw()
    ContainerControl.DrawChildren()
    ContainerControl.ContainsPoint(Float2, Boolean)
    ContainerControl.PerformLayout(Boolean)
    ContainerControl.RayCast(Float2, Control)
    ContainerControl.OnMouseMove(Float2)
    ContainerControl.OnMouseWheel(Float2, Single)
    ContainerControl.IsTouchPointerOver(Int32)
    ContainerControl.OnTouchEnter(Float2, Int32)
    ContainerControl.OnTouchMove(Float2, Int32)
    ContainerControl.OnTouchLeave(Int32)
    ContainerControl.OnCharInput(Char)
    ContainerControl.OnKeyDown(KeyboardKeys)
    ContainerControl.OnKeyUp(KeyboardKeys)
    ContainerControl.OnDragEnter(Float2, DragData)
    ContainerControl.OnDragMove(Float2, DragData)
    ContainerControl.OnDragLeave()
    ContainerControl.OnDragDrop(Float2, DragData)
    ContainerControl.OnSizeChanged()
    ContainerControl.Children
    ContainerControl.ChildrenCount
    ContainerControl.HasChildren
    ContainerControl.ContainsFocus
    ContainerControl.ClipChildren
    ContainerControl.CullChildren
    ContainerControl.IsTouchOver
    Control.Resize(Float2)
    Control.UpdateBounds()
    Control.UpdateTransform()
    Control.SetAnchorPreset(AnchorPresets, Boolean, Boolean)
    Control.Dispose()
    Control.Focus()
    Control.Defocus()
    Control.OnGotFocus()
    Control.OnStartContainsFocus()
    Control.OnEndContainsFocus()
    Control.Focus(Control)
    Control.StartMouseCapture(Boolean)
    Control.EndMouseCapture()
    Control.OnEndMouseCapture()
    Control.GetNavTarget(NavDirection)
    Control.GetNavOrigin(NavDirection)
    Control.NavigationFocus()
    Control.DoDragDrop(DragData)
    Control.LinkTooltip(String, Tooltip)
    Control.UnlinkTooltip()
    Control.OnShowTooltip(String, Float2, Rectangle)
    Control.OnTooltipShown(Tooltip)
    Control.OnTestTooltipOverControl(Float2)
    Control.IntersectsContent(Float2, Float2)
    Control.PointToParent(ContainerControl, Float2)
    Control.PointToParent(Float2)
    Control.PointToParent(Float2)
    Control.PointFromParent(Float2)
    Control.PointFromParent(Float2)
    Control.PointFromParent(ContainerControl, Float2)
    Control.PointToWindow(Float2)
    Control.PointFromWindow(Float2)
    Control.PointToScreen(Float2)
    Control.PointFromScreen(Float2)
    Control.OnLocationChanged()
    Control.SetScaleInternal(Float2)
    Control.SetPivotInternal(Float2)
    Control.SetShearInternal(Float2)
    Control.SetRotationInternal(Single)
    Control.OnVisibleChanged()
    Control.OnParentChangedInternal()
    Control.AddUpdateCallbacks(RootControl)
    Control.RemoveUpdateCallbacks(RootControl)
    Control.SetUpdate(Control.UpdateDelegate, Control.UpdateDelegate)
    Control.OnParentResized()
    Control.CompareTo(Object)
    Control.Compare(Control)
    Control.Top
    Control.Bottom
    Control.Left
    Control.Right
    Control.UpperLeft
    Control.UpperRight
    Control.BottomRight
    Control.BottomLeft
    Control.Scale
    Control.Pivot
    Control.Shear
    Control.Rotation
    Control.HasParent
    Control.BackgroundColor
    Control.BackgroundBrush
    Control.Enabled
    Control.EnabledInHierarchy
    Control.Visible
    Control.VisibleInHierarchy
    Control.IsDisposing
    Control.Root
    Control.RootWindow
    Control.DpiScale
    Control.ScreenPos
    Control.AutoFocus
    Control.IsFocused
    Control.IsNavFocused
    Control.IsMouseOver
    Control.IsDragOver
    Control.Tooltip
    Control.ShowTooltip
    Control.EditorBounds
    Control.LocationChanged
    Control.SizeChanged
    Control.ParentChanged
    Control.VisibleChanged
    Namespace: FlaxEngine.GUI
    Assembly: FlaxEngine.CSharp.dll
    Syntax
    [ActorToolbox("GUI")]
    public class Button : Label, IComparable, IDrawable

    Constructors

    Button()

    Initializes a new instance of the Button class.

    Declaration
    public 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
    ContainerControl.ClearState()

    DrawSelf()

    Draws the control.

    Declaration
    public override void DrawSelf()
    Overrides
    Label.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
    Control.OnLostFocus()

    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
    ContainerControl.OnMouseDoubleClick(Float2, MouseButton)

    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
    ContainerControl.OnMouseDown(Float2, MouseButton)

    OnMouseEnter(Float2)

    When mouse enters control's area

    Declaration
    public override void OnMouseEnter(Float2 location)
    Parameters
    Float2 location

    Mouse location in Control Space

    Overrides
    ContainerControl.OnMouseEnter(Float2)

    OnMouseLeave()

    When mouse leaves control's area

    Declaration
    public override void OnMouseLeave()
    Overrides
    ContainerControl.OnMouseLeave()

    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
    ContainerControl.OnMouseUp(Float2, MouseButton)

    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
    Control.OnSubmit()

    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
    ContainerControl.OnTouchDown(Float2, Int32)

    OnTouchLeave()

    When all touch leaves control's area

    Declaration
    public override void OnTouchLeave()
    Overrides
    Control.OnTouchLeave()

    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
    ContainerControl.OnTouchUp(Float2, Int32)

    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

    Extension Methods

    Extensions.ReflectiveCompare<T>(T, T)
    Extensions.DeepClone<T>(T)
    Extensions.RawClone<T>(T)
    In This Article
    Back to top Copyright © 2012-2024 Wojciech Figat