Table of Contents

Class TextBox

Namespace
PluginUI
Assembly
PluginUI.dll

Single-line text input: caret, selection (mouse, Shift+keys, double-click word), clipboard (Ctrl+A/C/X/V), word jumps (Ctrl+arrows), placeholder, filter, maximum length, read-only mode and an optional search look (magnifier and clear button).

public class TextBox : Control
Inheritance
TextBox
Inherited Members

Remarks

A plug-in window normally leaves the keyboard to the DAW; a text box takes the Win32 keyboard focus only while it is focused (RequestKeyboardFocus()), so typing does not trigger DAW shortcuts.

Constructors

TextBox()

Creates a text box.

public TextBox()

Properties

CaretIndex

Caret index.

public int CaretIndex { get; set; }

Property Value

int

CharacterFilter

Accepts or rejects typed characters (e.g. digits only).

[Browsable(false)]
public Func<char, bool>? CharacterFilter { get; set; }

Property Value

Func<char, bool>

CommitOnFocusLost

Raises Committed when the focus leaves.

public bool CommitOnFocusLost { get; set; }

Property Value

bool

DefaultSize

Natural size used when no explicit size is given.

protected override Size DefaultSize { get; }

Property Value

Size

IsInvalid

Marks the content as invalid: the frame is drawn in the palette's Danger color. Set by in-place editors (BeginTextEdit(Rect, string, Func<string, bool>, Action?, TextStyle?, Func<char, bool>?)) when a typed value is rejected; cleared automatically as soon as the text changes.

public bool IsInvalid { get; set; }

Property Value

bool

IsReadOnly

Prevents editing (selection and copy remain possible).

public bool IsReadOnly { get; set; }

Property Value

bool

IsSearchBox

Search look: magnifier on the left, clear button on the right.

public bool IsSearchBox { get; set; }

Property Value

bool

MaxLength

Maximum number of characters (0 = unlimited).

public int MaxLength { get; set; }

Property Value

int

Placeholder

Text shown dimmed while empty.

public string? Placeholder { get; set; }

Property Value

string

SelectAllOnFocus

Selects everything when the box receives the focus.

public bool SelectAllOnFocus { get; set; }

Property Value

bool

SelectedText

Selected text.

public string SelectedText { get; }

Property Value

string

SelectionLength

Length of the selection.

public int SelectionLength { get; }

Property Value

int

SelectionStart

Start of the selection.

public int SelectionStart { get; }

Property Value

int

Text

Text.

public string Text { get; set; }

Property Value

string

TextStyle

Text style (null = theme normal text, left aligned).

public TextStyle? TextStyle { get; set; }

Property Value

TextStyle

Methods

Insert(string)

Inserts text at the caret (replacing the selection), applying the filter and maximum length.

public void Insert(string text)

Parameters

text string

LayoutParts(VectorStyle, out Rect, out Rect, out Rect)

Splits the bounds into label (top), widget and value (bottom) areas according to the style. Override to change the arrangement (e.g. label on the left for sliders).

protected override void LayoutParts(VectorStyle style, out Rect label, out Rect widget, out Rect value)

Parameters

style VectorStyle
label Rect
widget Rect
value Rect

OnGotFocus()

Received keyboard focus.

protected override void OnGotFocus()

OnKeyDown(KeyEventArgs)

Key pressed while focused (bubbles to parents).

protected override void OnKeyDown(KeyEventArgs e)

Parameters

e KeyEventArgs

OnLostFocus()

Lost keyboard focus.

protected override void OnLostFocus()

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

OnTextInput(TextInputEventArgs)

Character typed while focused.

protected override void OnTextInput(TextInputEventArgs e)

Parameters

e TextInputEventArgs

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

Select(int, int)

Selects a range.

public void Select(int start, int length)

Parameters

start int
length int

SelectAll()

Selects all the text.

public void SelectAll()

Events

Cancelled

Raised when Escape is pressed.

public event Action<TextBox>? Cancelled

Event Type

Action<TextBox>

Committed

Raised when Enter is pressed (or the focus leaves after an edit when CommitOnFocusLost).

public event Action<TextBox, string>? Committed

Event Type

Action<TextBox, string>

TextChanged

Raised on every text change.

public event Action<TextBox, string>? TextChanged

Event Type

Action<TextBox, string>