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
CharacterFilter
Accepts or rejects typed characters (e.g. digits only).
[Browsable(false)]
public Func<char, bool>? CharacterFilter { get; set; }
Property Value
CommitOnFocusLost
Raises Committed when the focus leaves.
public bool CommitOnFocusLost { get; set; }
Property Value
DefaultSize
Natural size used when no explicit size is given.
protected override Size DefaultSize { get; }
Property Value
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
IsReadOnly
Prevents editing (selection and copy remain possible).
public bool IsReadOnly { get; set; }
Property Value
IsSearchBox
Search look: magnifier on the left, clear button on the right.
public bool IsSearchBox { get; set; }
Property Value
MaxLength
Maximum number of characters (0 = unlimited).
public int MaxLength { get; set; }
Property Value
Placeholder
Text shown dimmed while empty.
public string? Placeholder { get; set; }
Property Value
SelectAllOnFocus
Selects everything when the box receives the focus.
public bool SelectAllOnFocus { get; set; }
Property Value
SelectedText
Selected text.
public string SelectedText { get; }
Property Value
SelectionLength
Length of the selection.
public int SelectionLength { get; }
Property Value
SelectionStart
Start of the selection.
public int SelectionStart { get; }
Property Value
Text
Text.
public string Text { get; set; }
Property Value
TextStyle
Text style (null = theme normal text, left aligned).
public TextStyle? TextStyle { get; set; }
Property Value
Methods
Insert(string)
Inserts text at the caret (replacing the selection), applying the filter and maximum length.
public void Insert(string text)
Parameters
textstring
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
styleVectorStylelabelRectwidgetRectvalueRect
OnGotFocus()
Received keyboard focus.
protected override void OnGotFocus()
OnKeyDown(KeyEventArgs)
Key pressed while focused (bubbles to parents).
protected override void OnKeyDown(KeyEventArgs e)
Parameters
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
OnMouseMove(MouseEventArgs)
Mouse moved over the element (or captured).
protected override void OnMouseMove(MouseEventArgs e)
Parameters
OnMouseUp(MouseEventArgs)
Mouse button released.
protected override void OnMouseUp(MouseEventArgs e)
Parameters
OnTextInput(TextInputEventArgs)
Character typed while focused.
protected override void OnTextInput(TextInputEventArgs e)
Parameters
RenderVector(DrawingContext, Rect, VectorStyle)
Vector rendering of the widget area.
protected override void RenderVector(DrawingContext dc, Rect widget, VectorStyle style)
Parameters
dcDrawingContextwidgetRectstyleVectorStyle
Select(int, int)
Selects a range.
public void Select(int start, int length)
Parameters
SelectAll()
Selects all the text.
public void SelectAll()
Events
Cancelled
Raised when Escape is pressed.
public event Action<TextBox>? Cancelled
Event Type
Committed
Raised when Enter is pressed (or the focus leaves after an edit when CommitOnFocusLost).
public event Action<TextBox, string>? Committed
Event Type
TextChanged
Raised on every text change.
public event Action<TextBox, string>? TextChanged