Table of Contents

Class TextBox

Namespace
RichHudFramework.UI
Assembly
RichHudClient.dll

Interactive, clickable text box with caret and highlighting. Text only, no background or scrollbars.

public class TextBox : Label, IReadOnlyHudElement, IReadOnlyHudNode, IReadOnlyHudParent, IMinLabelElement, IClickableElement, IBindInputElement, IFocusableElement, IValueControl<ITextBuilder>, IValueControl
Inheritance
TextBox
Implements
Inherited Members

Constructors

TextBox()

public TextBox()

TextBox(HudParentBase)

public TextBox(HudParentBase parent)

Parameters

parent HudParentBase

Properties

BindInput

Custom bind input interface for this element. Handles input events for cut, copy, paste, etc.

public IBindInput BindInput { get; }

Property Value

IBindInput

CaretPosition

Index of the character currently selected by the caret.

public Vector2I CaretPosition { get; }

Property Value

Vector2I

CharFilterFunc

Used to restrict the range of characters allowed for input.

public Func<char, bool> CharFilterFunc { get; set; }

Property Value

Func<char, bool>

ClearSelectionOnLoseFocus

If true, any text selections will be cleared when focus is lost.

public bool ClearSelectionOnLoseFocus { get; set; }

Property Value

bool

EnableEditing

Determines whether or not the textbox will allow the user to edit its contents

public bool EnableEditing { get; set; }

Property Value

bool

EnableHighlighting

Determines whether the user will be allowed to highlight text

public bool EnableHighlighting { get; set; }

Property Value

bool

FocusHandler

Interface used to manage the element's input focus state

public IFocusHandler FocusHandler { get; }

Property Value

IFocusHandler

InputOpen

Indicates whether or not the textbox will accept input

public bool InputOpen { get; }

Property Value

bool

IsMousedOver

Indicates whether or not the element is capturing the cursor.

public override bool IsMousedOver { get; }

Property Value

bool

MouseInput

Mouse input interface for this clickable element

public IMouseInput MouseInput { get; }

Property Value

IMouseInput

MoveToEndOnGainFocus

If true, the caret will move to the end of the text when it gains focus.

public bool MoveToEndOnGainFocus { get; set; }

Property Value

bool

NewLineChar

Alternative line break character. Useful if Enter/Return is unavailable.

public char NewLineChar { get; set; }

Property Value

char

SelectionEmpty

If true, then text box currently has a range of characters selected.

public bool SelectionEmpty { get; }

Property Value

bool

SelectionEnd

Index of the last character in the selected range.

public Vector2I SelectionEnd { get; }

Property Value

Vector2I

SelectionStart

Index of the first character in the selected range.

public Vector2I SelectionStart { get; }

Property Value

Vector2I

UpdateValueCallback

Registers a text update callback. For use in object initializers.

public EventHandler UpdateValueCallback { set; }

Property Value

EventHandler

Value

Returns an interface to the rich text content of the control.

Supports object.ToString() for getting plain text copies.

public ITextBuilder Value { get; }

Property Value

ITextBuilder

Methods

ClearSelection()

Clears selected text range.

public void ClearSelection()

ClearSelection(object, EventArgs)

Handles clearing selection on left click or escape

protected virtual void ClearSelection(object sender, EventArgs args)

Parameters

sender object
args EventArgs

CloseInput()

Closes textbox input and clears the text selection.

public void CloseInput()

CopyText(object, EventArgs)

Copies the currently selected text to the clipboard if input is allowed and highlighting is enabled.

protected virtual void CopyText(object sender, EventArgs args)

Parameters

sender object
args EventArgs

CutText(object, EventArgs)

Cuts the currently selected text to the clipboard if input is allowed, editing is enabled, and highlighting is enabled. Deletes the selection and adjusts the caret position accordingly.

protected virtual void CutText(object sender, EventArgs args)

Parameters

sender object
args EventArgs

GainFocus(object, EventArgs)

Handles gaining input focus. Moves caret to end if configured to do so.

protected virtual void GainFocus(object sender, EventArgs args)

Parameters

sender object
args EventArgs

HandleTextChange()

Marks a text change as pending invocation of the TextChanged event.

protected virtual void HandleTextChange()

LoseFocus(object, EventArgs)

Handles losing input focus. Clears selection if configured to do so.

protected virtual void LoseFocus(object sender, EventArgs args)

Parameters

sender object
args EventArgs

OpenInput()

Opens the textbox for input and moves the caret to the end.

public void OpenInput()

PasteText(object, EventArgs)

Pastes the clipboard text at the caret position if input is allowed and editing is enabled. Replaces any existing selection and adjusts the caret position.

protected virtual void PasteText(object sender, EventArgs args)

Parameters

sender object
args EventArgs

SelectAllText(object, EventArgs)

Selects all text in the textbox if input is allowed and highlighting is enabled. Moves the caret to the end and sets the full text range as the selection.

protected virtual void SelectAllText(object sender, EventArgs args)

Parameters

sender object
args EventArgs

SetSelection(Vector2I, Vector2I)

Highlights the range of text specified.

public void SetSelection(Vector2I start, Vector2I end)

Parameters

start Vector2I
end Vector2I

Events

ValueChanged

Invoked whenever a change is made to the text. Invokes once every 500ms, at most.

public event EventHandler ValueChanged

Event Type

EventHandler