Class TextInputBaseField<TValueType>
Abstract base class used for all text-based fields.
Inherited Members
Namespace: UnityEngine.UIElements
Syntax
public abstract class TextInputBaseField<TValueType> : BaseField<TValueType>, IEventHandler, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IResolvedStyle, IBindable, INotifyValueChanged<TValueType>, IMixedValueSupport
Type Parameters
Name | Description |
---|---|
TValueType |
Constructors
TextInputBaseField(Int32, Char, TextInputBaseField<TValueType>.TextInputBase)
Declaration
protected TextInputBaseField(int maxLength, char maskChar, TextInputBaseField<TValueType>.TextInputBase textInputBase)
Parameters
Type | Name | Description |
---|---|---|
Int32 | maxLength | |
Char | maskChar | |
TextInputBaseField.TextInputBase<> | textInputBase |
TextInputBaseField(String, Int32, Char, TextInputBaseField<TValueType>.TextInputBase)
Declaration
protected TextInputBaseField(string label, int maxLength, char maskChar, TextInputBaseField<TValueType>.TextInputBase textInputBase)
Parameters
Type | Name | Description |
---|---|---|
String | label | |
Int32 | maxLength | |
Char | maskChar | |
TextInputBaseField.TextInputBase<> | textInputBase |
Fields
inputUssClassName
USS class name of input elements in elements of this type.
Declaration
public static readonly string inputUssClassName
Field Value
Type | Description |
---|---|
String |
labelUssClassName
USS class name of labels in elements of this type.
Declaration
public static readonly string labelUssClassName
Field Value
Type | Description |
---|---|
String |
multilineInputUssClassName
USS class name of multiline input elements in elements of this type.
Declaration
public static readonly string multilineInputUssClassName
Field Value
Type | Description |
---|---|
String |
singleLineInputUssClassName
USS class name of single line input elements in elements of this type.
Declaration
public static readonly string singleLineInputUssClassName
Field Value
Type | Description |
---|---|
String |
textInputUssName
USS class name of input elements in elements of this type.
Declaration
public static readonly string textInputUssName
Field Value
Type | Description |
---|---|
String |
ussClassName
USS class name of elements of this type.
Declaration
public static readonly string ussClassName
Field Value
Type | Description |
---|---|
String |
Properties
cursorColor
Color of the cursor.
Declaration
public Color cursorColor { get; }
Property Value
Type | Description |
---|---|
Color |
cursorIndex
The current cursor position index in the text input field.
Declaration
public int cursorIndex { get; }
Property Value
Type | Description |
---|---|
Int32 |
doubleClickSelectsWord
Controls whether double clicking selects the word under the mouse pointer or not.
Declaration
public bool doubleClickSelectsWord { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
isDelayed
If set to true, the value property isn't updated until either the user presses Enter or the text field loses focus.
Declaration
public bool isDelayed { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
isPasswordField
Returns true if the field is used to edit a password.
Declaration
public bool isPasswordField { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
isReadOnly
Returns true if the field is read only.
Declaration
public bool isReadOnly { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
maskChar
The character used for masking in a password field.
Declaration
public char maskChar { get; set; }
Property Value
Type | Description |
---|---|
Char |
maxLength
Maximum number of characters for the field.
Declaration
public int maxLength { get; set; }
Property Value
Type | Description |
---|---|
Int32 |
selectIndex
The current selection position index in the text input field.
Declaration
public int selectIndex { get; }
Property Value
Type | Description |
---|---|
Int32 |
selectionColor
Background color of selected text.
Declaration
public Color selectionColor { get; }
Property Value
Type | Description |
---|---|
Color |
text
The value of the input field.
Declaration
public string text { get; protected set; }
Property Value
Type | Description |
---|---|
String |
textInputBase
This is the text input visual element which presents the value in the field.
Declaration
protected TextInputBaseField<TValueType>.TextInputBase textInputBase { get; }
Property Value
Type | Description |
---|---|
TextInputBaseField.TextInputBase<> |
tripleClickSelectsLine
Controls whether triple clicking selects the entire line under the mouse pointer or not.
Declaration
public bool tripleClickSelectsLine { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Methods
ExecuteDefaultActionAtTarget(EventBase)
Declaration
protected override void ExecuteDefaultActionAtTarget(EventBase evt)
Parameters
Type | Name | Description |
---|---|---|
EventBase | evt |
Overrides
MeasureTextSize(String, Single, VisualElement.MeasureMode, Single, VisualElement.MeasureMode)
Computes the size needed to display a text string based on element style values such as font, font-size, and word-wrap.
Declaration
public Vector2 MeasureTextSize(string textToMeasure, float width, VisualElement.MeasureMode widthMode, float height, VisualElement.MeasureMode heightMode)
Parameters
Type | Name | Description |
---|---|---|
String | textToMeasure | The text to measure. |
Single | width | Suggested width. Can be zero. |
VisualElement.MeasureMode | widthMode | Width restrictions. |
Single | height | Suggested height. |
VisualElement.MeasureMode | heightMode | Height restrictions. |
Returns
Type | Description |
---|---|
Vector2 | The horizontal and vertical size needed to display the text string. |
SelectAll()
Selects all the text.
Declaration
public void SelectAll()
StringToValue(String)
Converts a string to the value of the specified generic type from the subclass.
Declaration
protected virtual TValueType StringToValue(string str)
Parameters
Type | Name | Description |
---|---|---|
String | str | The string to convert. |
Returns
Type | Description |
---|---|
TValueType | A value converted from the string. |
Remarks
Subclasses must implement this method.
UpdateMixedValueContent()
Declaration
protected override void UpdateMixedValueContent()
Overrides
ValueToString(TValueType)
Converts a value of the specified generic type from the subclass to a string representation.
Declaration
protected virtual string ValueToString(TValueType value)
Parameters
Type | Name | Description |
---|---|---|
TValueType | value | The value to convert. |
Returns
Type | Description |
---|---|
String | A string representing the value. |
Remarks
Subclasses must implement this method.
Events
onIsReadOnlyChanged
Calls the methods in its invocation list when isReadOnly changes.
Declaration
protected event Action<bool> onIsReadOnlyChanged
Event Type
Type | Description |
---|---|
Action<Boolean> |