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.
public sealed class Button : WidgetInheritance
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.
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).
public override bool Focusable { get; }Property Value
Text
The label; null counts as empty.
public string Text { get; set; }Property Value
Methods
Click()
Clicks the button as confirm or the pointer would: raises Clicked unless it is disabled. Returns whether it did.
public bool Click()Returns
DrawContent(IRenderer, UiContext)
Draws the widget in Bounds, and its children.
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.
protected override Vector2 MeasureContent(UiContext context)Parameters
context UiContext
Returns
OnAction(UiAction)
Called for an action while the widget has the focus; return true when it acted, which consumes the action.
protected override bool OnAction(UiAction action)Parameters
action UiAction
Returns
OnClick()
Called when a pointer press that started on the widget is released on it, after OnPointerUp.
protected override void OnClick()Clicked
Raised when the button is clicked.
public event Action? Clicked