TextBox Class
Definition
Section titled “Definition”InputBox control that allows text input.
[DataContract]public class TextBox : ControlBaseInheritance object → ControlBase
Constructors
Section titled “Constructors”TextBox(int)
Section titled “TextBox(int)”Creates a new instance of the input box.
public TextBox(int width)Parameters
Section titled “Parameters”width int
The width of the input box.
Fields
Section titled “Fields”_cachedBuilder
Section titled “_cachedBuilder”String builder used while processing text in the ProcessKeyboard(Keyboard) method.
protected StringBuilder? _cachedBuilder_caretPos
Section titled “_caretPos”The location of the caret.
protected int _caretPosThe text value of the input box.
[DataMember(Name = "Text")]protected string _textProperties
Section titled “Properties”Mask input with a certain character.
public char? Mask { get; set; }LeftDrawOffset
Section titled “LeftDrawOffset”When editing the text box, this allows the text to scroll to the right so you can see what you are typing.
public int LeftDrawOffset { get; protected set; }DisableMouse
Section titled “DisableMouse”Disables mouse input.
[DataMember(Name = "DisableMouseInput")]public bool DisableMouse { get; set; }DisableKeyboard
Section titled “DisableKeyboard”Disables the keyboard which turns off keyboard input and hides the cursor.
[DataMember(Name = "DisableKeyboardInput")]public bool DisableKeyboard { get; set; }MaxLength
Section titled “MaxLength”How big the text can be. Setting this to 0 will make it unlimited.
[DataMember]public int MaxLength { get; set; }Validator
Section titled “Validator”When set, validates the Text property after TextChangedPreview has allowed the result.
public StringValidation.Validator? Validator { get; set; }CaretPosition
Section titled “CaretPosition”Gets or sets the position of the caret in the current text.
public int CaretPosition { get; set; }Gets or sets the text of the input box.
public string Text { get; set; }CaretEffect
Section titled “CaretEffect”The style to use for the carrot.
[DataMember]public ICellEffect CaretEffect { get; set; }UseDifferentTextAreaWidth
Section titled “UseDifferentTextAreaWidth”Enables displaying the text area at a different width than the width of the control.
public bool UseDifferentTextAreaWidth { get; set; }TextAreaWidth
Section titled “TextAreaWidth”The width to display the text area at when UseDifferentTextAreaWidth is true.
public int TextAreaWidth { get; set; }Methods
Section titled “Methods”Resize(int, int)
Section titled “Resize(int, int)”Resizes the control if the CanResize property is true.
public override void Resize(int width, int height)Parameters
Section titled “Parameters”width int
The desired width of the control.
height int
The desired height of the control.
ValidateCursorPosition(string)
Section titled “ValidateCursorPosition(string)”Correctly positions the cursor within the text.
protected void ValidateCursorPosition(string text)Parameters
Section titled “Parameters”text string
CheckKeyPressCancel(AsciiKey)
Section titled “CheckKeyPressCancel(AsciiKey)”Raises the KeyPressed event and returns true if the keypress was cancelled.
protected bool CheckKeyPressCancel(AsciiKey key)Parameters
Section titled “Parameters”key AsciiKey
The key to use with the event.
Returns
Section titled “Returns”bool
true to indicate that the keypress should be considered cancelled.
ProcessKeyboard(Keyboard)
Section titled “ProcessKeyboard(Keyboard)”Called when the control should process keyboard information.
public override bool ProcessKeyboard(Keyboard info)Parameters
Section titled “Parameters”info Keyboard
The keyboard information.
Returns
Section titled “Returns”bool
True if the keyboard was handled by this control.
OnUnfocused()
Section titled “OnUnfocused()”Called when the control loses focus.
protected override void OnUnfocused()OnFocused()
Section titled “OnFocused()”Called when the control is focused.
protected override void OnFocused()OnLeftMouseClicked(ControlMouseState)
Section titled “OnLeftMouseClicked(ControlMouseState)”Focuses the control and enters typing mode.
protected override void OnLeftMouseClicked(ControlBase.ControlMouseState state)Parameters
Section titled “Parameters”state ControlBase.ControlMouseState
The mouse state.
UpdateAndRedraw(TimeSpan)
Section titled “UpdateAndRedraw(TimeSpan)”Redraws the control if applicable.
public override void UpdateAndRedraw(TimeSpan time)Parameters
Section titled “Parameters”time TimeSpan
The duration of thecurrent frame.
Events
Section titled “Events”TextChanged
Section titled “TextChanged”Raised when the text has changed and the preview has accepted it.
public event EventHandler? TextChangedEvent Type
Section titled “Event Type”TextChangedPreview
Section titled “TextChangedPreview”Raised before the text has changed and allows the change to be cancelled.
public event EventHandler<ValueChangedCancelableEventArgs<string>>? TextChangedPreviewEvent Type
Section titled “Event Type”EventHandler<ValueChangedCancelableEventArgs<string>>
KeyPressed
Section titled “KeyPressed”Raised when a key is pressed on the textbox.
public event EventHandler<KeyPressEventArgs>? KeyPressedEvent Type
Section titled “Event Type”EventHandler<KeyPressEventArgs>
TextValidated
Section titled “TextValidated”Raised when the Validator validates the Text property.
public event EventHandler<StringValidation.Result>? TextValidated