Skip to content

API reference

Class Button

Namespace: MicroEngine.UI
Assembly: MicroEngine.UI.dll
Guide: UI widgets

A button: confirm while it has the focus, or a click (a press and release of the pointer on it), raises Clicked. It takes the focus.

C#
public sealed class Button : Widget

Inheritance

object ← Widget ← Button

Inherited Members

Widget.Measure(UiContext), Widget.Arrange(RectF, UiContext), Widget.Draw(IRenderer, UiContext), Widget.Bounds, Widget.Visible, Widget.Enabled, Widget.Width, Widget.Height, Widget.Offset, Widget.Opacity, Widget.BlocksPointer, Widget.Parent, Widget.Root, Widget.Children, Widget.Focusable, Widget.ClipsChildren, Widget.IsFocused, Widget.IsHovered, Widget.IsPressed, Widget.IsEnabledInTree, Widget.IsVisibleInTree, object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Constructors

Button(string, Action?)

A button labelled text, calling clicked (optional) when clicked.

C#
public Button(string text, Action? clicked = null)

Parameters

text string

clicked Action?

Properties

Focusable

Whether the widget can take the focus (false by default; buttons and text fields can).

C#
public override bool Focusable { get; }

Property Value

bool

Text

The label; null counts as empty.

C#
public string Text { get; set; }

Property Value

string

Methods

Click()

Clicks the button as confirm or the pointer would: raises Clicked unless it is disabled. Returns whether it did.

C#
public bool Click()

Returns

bool

DrawContent(IRenderer, UiContext)

Draws the widget in Bounds, and its children.

C#
protected override void DrawContent(IRenderer renderer, UiContext context)

Parameters

renderer IRenderer

context UiContext

MeasureContent(UiContext)

The size the widget’s content needs, in UI units.

C#
protected override Vector2 MeasureContent(UiContext context)

Parameters

context UiContext

Returns

Vector2

OnAction(UiAction)

Called for an action while the widget has the focus; return true when it acted, which consumes the action.

C#
protected override bool OnAction(UiAction action)

Parameters

action UiAction

Returns

bool

OnClick()

Called when a pointer press that started on the widget is released on it, after OnPointerUp.

C#
protected override void OnClick()

Clicked

Raised when the button is clicked.

C#
public event Action? Clicked

Event Type

Action?