Skip to content

TextBox Class

InputBox control that allows text input.

C#
[DataContract]
public class TextBox : ControlBase

Inheritance objectControlBase

Creates a new instance of the input box.

C#
public TextBox(int width)

width int
The width of the input box.

String builder used while processing text in the ProcessKeyboard(Keyboard) method.

C#
protected StringBuilder? _cachedBuilder

The location of the caret.

C#
protected int _caretPos

The text value of the input box.

C#
[DataMember(Name = "Text")]
protected string _text

Mask input with a certain character.

C#
public char? Mask { get; set; }

When editing the text box, this allows the text to scroll to the right so you can see what you are typing.

C#
public int LeftDrawOffset { get; protected set; }

Disables mouse input.

C#
[DataMember(Name = "DisableMouseInput")]
public bool DisableMouse { get; set; }

Disables the keyboard which turns off keyboard input and hides the cursor.

C#
[DataMember(Name = "DisableKeyboardInput")]
public bool DisableKeyboard { get; set; }

How big the text can be. Setting this to 0 will make it unlimited.

C#
[DataMember]
public int MaxLength { get; set; }

When set, validates the Text property after TextChangedPreview has allowed the result.

C#
public StringValidation.Validator? Validator { get; set; }

Gets or sets the position of the caret in the current text.

C#
public int CaretPosition { get; set; }

Gets or sets the text of the input box.

C#
public string Text { get; set; }

The style to use for the carrot.

C#
[DataMember]
public ICellEffect CaretEffect { get; set; }

Enables displaying the text area at a different width than the width of the control.

C#
public bool UseDifferentTextAreaWidth { get; set; }

The width to display the text area at when UseDifferentTextAreaWidth is true.

C#
public int TextAreaWidth { get; set; }

Resizes the control if the CanResize property is true.

C#
public override void Resize(int width, int height)

width int
The desired width of the control.

height int
The desired height of the control.

Correctly positions the cursor within the text.

C#
protected void ValidateCursorPosition(string text)

text string

Raises the KeyPressed event and returns true if the keypress was cancelled.

C#
protected bool CheckKeyPressCancel(AsciiKey key)

key AsciiKey
The key to use with the event.

bool
true to indicate that the keypress should be considered cancelled.

Called when the control should process keyboard information.

C#
public override bool ProcessKeyboard(Keyboard info)

info Keyboard
The keyboard information.

bool
True if the keyboard was handled by this control.

Called when the control loses focus.

C#
protected override void OnUnfocused()

Called when the control is focused.

C#
protected override void OnFocused()

Focuses the control and enters typing mode.

C#
protected override void OnLeftMouseClicked(ControlBase.ControlMouseState state)

state ControlBase.ControlMouseState
The mouse state.

Redraws the control if applicable.

C#
public override void UpdateAndRedraw(TimeSpan time)

time TimeSpan
The duration of thecurrent frame.

Raised when the text has changed and the preview has accepted it.

C#
public event EventHandler? TextChanged

EventHandler

Raised before the text has changed and allows the change to be cancelled.

C#
public event EventHandler<ValueChangedCancelableEventArgs<string>>? TextChangedPreview

EventHandler<ValueChangedCancelableEventArgs<string>>

Raised when a key is pressed on the textbox.

C#
public event EventHandler<KeyPressEventArgs>? KeyPressed

EventHandler<KeyPressEventArgs>

Raised when the Validator validates the Text property.

C#
public event EventHandler<StringValidation.Result>? TextValidated

EventHandler<StringValidation.Result>