Table of Contents

Class Button

Namespace
PluginUI
Assembly
PluginUI.dll

Momentary push button with text and/or icon (bitmap, SVG or vector callback). Raises Click on release over the button (or repeatedly while held when RepeatWhileHeld), and can drive a parameter as a momentary switch (1 while pressed, 0 when released).

public class Button : Control
Inheritance
Button
Inherited Members

Constructors

Button()

Creates a button.

public Button()

Button(string, Action?)

Creates a button with a caption and an optional click action.

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

Parameters

text string
clicked Action

Properties

Appearance

Visual variant.

public ButtonAppearance Appearance { get; set; }

Property Value

ButtonAppearance

Clicked

Action invoked on click (command style).

[Browsable(false)]
public Action? Clicked { get; set; }

Property Value

Action

DefaultSize

Natural size used when no explicit size is given.

protected override Size DefaultSize { get; }

Property Value

Size

IconRenderer

Vector icon callback: draws into the icon rectangle with the given foreground color.

[Browsable(false)]
public Action<DrawingContext, Rect, Color>? IconRenderer { get; set; }

Property Value

Action<DrawingContext, Rect, Color>

IconSize

Icon size in DIPs.

public float IconSize { get; set; }

Property Value

float

Image

Bitmap icon (drawn left of the text, or centered without text).

public ImageSource? Image { get; set; }

Property Value

ImageSource

Parameter

Optional parameter driven as a momentary switch (1 while pressed).

public IParameter? Parameter { get; set; }

Property Value

IParameter

RepeatDelay

Delay before auto-repeat starts (seconds).

public double RepeatDelay { get; set; }

Property Value

double

RepeatInterval

Auto-repeat interval (seconds).

public double RepeatInterval { get; set; }

Property Value

double

RepeatWhileHeld

Fires Click on press, then repeatedly while held.

public bool RepeatWhileHeld { get; set; }

Property Value

bool

ShowContentOverSkin

Draws the text and icon over a Skin (bitmap frames without baked-in text).

public bool ShowContentOverSkin { get; set; }

Property Value

bool

Svg

SVG icon.

public SvgImage? Svg { get; set; }

Property Value

SvgImage

Text

Caption drawn inside the button.

public string? Text { get; set; }

Property Value

string

TextStyle

Text style (null = theme normal text, centered, medium weight).

public TextStyle? TextStyle { get; set; }

Property Value

TextStyle

Methods

ForegroundColor(VectorStyle)

Foreground color for the current state.

protected Color ForegroundColor(VectorStyle style)

Parameters

style VectorStyle

Returns

Color

OnCaptureLost()

The mouse capture was lost without a button release.

protected override void OnCaptureLost()

OnClick()

Called on every click (after the events).

protected virtual void OnClick()

OnDetached()

Called when the element leaves its host (unsubscribe here).

protected override void OnDetached()

OnKeyDown(KeyEventArgs)

Key pressed while focused (bubbles to parents).

protected override void OnKeyDown(KeyEventArgs e)

Parameters

e KeyEventArgs

OnMouseDown(MouseEventArgs)

Mouse button pressed over the element (or captured).

protected override void OnMouseDown(MouseEventArgs e)

Parameters

e MouseEventArgs

OnMouseMove(MouseEventArgs)

Mouse moved over the element (or captured).

protected override void OnMouseMove(MouseEventArgs e)

Parameters

e MouseEventArgs

OnMouseUp(MouseEventArgs)

Mouse button released.

protected override void OnMouseUp(MouseEventArgs e)

Parameters

e MouseEventArgs

OnRender(DrawingContext)

Draws the element (below its children).

protected override void OnRender(DrawingContext dc)

Parameters

dc DrawingContext

PerformClick()

Raises the click (also callable from code).

public void PerformClick()

RenderContent(DrawingContext, Rect, Color)

Draws icon and text centered in r.

protected virtual void RenderContent(DrawingContext dc, Rect r, Color foreground)

Parameters

dc DrawingContext
r Rect
foreground Color

RenderVector(DrawingContext, Rect, VectorStyle)

Vector rendering of the widget area.

protected override void RenderVector(DrawingContext dc, Rect widget, VectorStyle style)

Parameters

dc DrawingContext
widget Rect
style VectorStyle

Events

Click

Raised when the button is clicked.

public event Action<Button>? Click

Event Type

Action<Button>