Class TextField
- Namespace
- UILib.Components
- Assembly
- UILib.dll
A component which holds text that a user can edit.
public class TextField : UIComponent
- Inheritance
-
TextField
- Inherited Members
Constructors
TextField(string, int)
Initializes a text field.
public TextField(string text, int fontSize)
Parameters
Properties
background
The background of this text field.
public Image background { get; }
Property Value
- Image
clearMode
In which cases will this text field wipe its input and value.
Note: Clear modes will override equivalent retain modes.
Default: None
public TextField.ClearMode clearMode { get; }
Property Value
input
The label containing the user input.
public Label input { get; }
Property Value
onCancel
Invokes listeners when the user cancels entering text.
public UnityEvent onCancel { get; }
Property Value
- UnityEvent
onInputChanged
Invokes listeners when the user starts typing something in the input field.
The value listeners receive is the text the user is typing not the value which is actually stored in this text field.
public ValueEvent<string> onInputChanged { get; }
Property Value
onInvalidSubmit
Invokes listeners with the user's input when they submit something invalid.
public ValueEvent<string> onInvalidSubmit { get; }
Property Value
onValidSubmit
Invokes listeners with the current value stored when the user submits it.
The value listeners receive is the value stored in this text field.
If you have set a predicate, this only triggers if the user's input was valid.
public ValueEvent<string> onValidSubmit { get; }
Property Value
placeholder
The placeholder label.
public Label placeholder { get; }
Property Value
retainFocus
Whether this text field will retain its focus after the user submits an input.
False by default.
public bool retainFocus { get; }
Property Value
retainMode
In which extra cases will this text field retain the current user input.
The input will always be retained on a valid submit.
Default: None
public TextField.RetainMode retainMode { get; }
Property Value
submitMode
Which extra interactions with the text field will count as a submit.
Default: None
public TextField.SubmitMode submitMode { get; }
Property Value
userInput
The current user input (displayed text).
public string userInput { get; }
Property Value
value
The current value stored in this text field. This only updates whenever the user submits a valid input.
public string value { get; }
Property Value
Methods
SetAlignment(AnchorType)
Sets the alignment of the text.
public void SetAlignment(AnchorType alignment)
Parameters
alignmentAnchorTypeThe alignment to use
SetClearMode(ClearMode)
Sets when this text field should clear the user input and its value.
Note: Clear modes will override equivalent retain modes.
public void SetClearMode(TextField.ClearMode clearMode)
Parameters
SetPredicate(Func<string, bool>)
Sets the predicate to use for validating the user's input.
public void SetPredicate(Func<string, bool> predicate)
Parameters
SetRetainFocus(bool)
Sets whether this text field should retain focus.
public void SetRetainFocus(bool retainFocus)
Parameters
retainFocusboolWhether to retain focus
SetRetainMode(RetainMode)
Sets in which cases this text field will retain the current user input.
The input will always be retained on a valid submit.
public void SetRetainMode(TextField.RetainMode retainMode)
Parameters
retainModeTextField.RetainModeWhich cases the input should be retained
SetSubmitMode(SubmitMode)
Sets which interactions with this text field will count as a submit.
public void SetSubmitMode(TextField.SubmitMode submitMode)
Parameters
submitModeTextField.SubmitModeWhich cases will count as a submit
SetText(string)
Sets the text displayed by this text field.
public void SetText(string text)
Parameters
textstringThe text to display
SetThisTheme(Theme)
Allows setting the theme of this text field.
This handles setting the theme specifically for this component, not its children. It's protected to allow overriding if you were to create a subclass.
In most cases, you'd probably want to use SetTheme(Theme) instead.
protected override void SetThisTheme(Theme theme)
Parameters
themeThemeThe theme to apply
SetValue(string)
Sets the current value stored in this text field. Updates the internal value and the text displayed in the input field.
public void SetValue(string value)
Parameters
valuestringThe value to set