Class TextField
A textfield is a rectangular area where the user can edit a string.
Inheritance
Inherited Members
Namespace: UnityEngine.UIElements
Syntax
public class TextField : TextInputBaseField<string>, IEventHandler, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IResolvedStyle, IBindable, INotifyValueChanged<string>, IMixedValueSupport
Constructors
TextField()
Creates a new textfield.
Declaration
public TextField()
TextField(Int32, Boolean, Boolean, Char)
Creates a new textfield.
Declaration
public TextField(int maxLength, bool multiline, bool isPasswordField, char maskChar)
Parameters
Type | Name | Description |
---|---|---|
Int32 | maxLength | The maximum number of characters this textfield can hold. If 0, there is no limit. |
Boolean | multiline | Set this to true to allow multiple lines in the textfield and false if otherwise. |
Boolean | isPasswordField | Set this to true to mask the characters and false if otherwise. |
Char | maskChar | The character used for masking in a password field. |
TextField(String)
Creates a new textfield.
Declaration
public TextField(string label)
Parameters
Type | Name | Description |
---|---|---|
String | label |
TextField(String, Int32, Boolean, Boolean, Char)
Creates a new textfield.
Declaration
public TextField(string label, int maxLength, bool multiline, bool isPasswordField, char maskChar)
Parameters
Type | Name | Description |
---|---|---|
String | label | |
Int32 | maxLength | The maximum number of characters this textfield can hold. If 0, there is no limit. |
Boolean | multiline | Set this to true to allow multiple lines in the textfield and false if otherwise. |
Boolean | isPasswordField | Set this to true to mask the characters and false if otherwise. |
Char | maskChar | The character used for masking in a password field. |
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 |
ussClassName
USS class name of elements of this type.
Declaration
public static readonly string ussClassName
Field Value
Type | Description |
---|---|
String |
Properties
multiline
Set this to true to allow multiple lines in the textfield and false if otherwise.
Declaration
public bool multiline { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
value
The string currently being exposed by the field.
Declaration
public override string value { get; set; }
Property Value
Type | Description |
---|---|
String |
Overrides
Remarks
Note that changing this will not trigger a change event to be sent.
Methods
SelectRange(Int32, Int32)
Selects text in the textfield between cursorIndex and selectionIndex.
Declaration
public void SelectRange(int rangeCursorIndex, int selectionIndex)
Parameters
Type | Name | Description |
---|---|---|
Int32 | rangeCursorIndex | |
Int32 | selectionIndex | The selection end position. |
SetValueWithoutNotify(String)
Declaration
public override void SetValueWithoutNotify(string newValue)
Parameters
Type | Name | Description |
---|---|---|
String | newValue |
Overrides
StringToValue(String)
Declaration
protected override string StringToValue(string str)
Parameters
Type | Name | Description |
---|---|---|
String | str |
Returns
Type | Description |
---|---|
String |
Overrides
ValueToString(String)
Declaration
protected override string ValueToString(string value)
Parameters
Type | Name | Description |
---|---|---|
String | value |
Returns
Type | Description |
---|---|
String |