Method TextField
- Namespace
- Velvet
- Assembly
- Velvet.Docs.dll
TextField(string?, string?, Action<string>?, string?, string?, string?, bool?, bool?, Func<VisualElement, Action>?, string?, string?, string?, IReadOnlyDictionary<string, string>?, IReadOnlyDictionary<string, string>?, string?, int?, bool?, bool?, bool?, TouchScreenKeyboardType?, bool?, Action<string>?, EventCallback<KeyDownEvent>?, EventCallback<KeyUpEvent>?, EventCallback<FocusInEvent>?, EventCallback<FocusOutEvent>?, Action<VisualElement>?, FiberEventBinding[]?)
Creates a TextField.
public static ElementNode TextField(string? className = null, string? value = null, Action<string>? onValueChanged = null, string? key = null, string? name = null, string? label = null, bool? isPasswordField = null, bool? enabled = null, Func<VisualElement, Action>? refCallback = null, string? whileHoverClass = null, string? whileTapClass = null, string? whileFocusClass = null, IReadOnlyDictionary<string, string>? data = null, IReadOnlyDictionary<string, string>? aria = null, string? placeholder = null, int? maxLength = null, bool? isReadOnly = null, bool? isDelayed = null, bool? multiline = null, TouchScreenKeyboardType? keyboardType = null, bool? autoCorrection = null, Action<string>? onSubmit = null, EventCallback<KeyDownEvent>? onKeyDown = null, EventCallback<KeyUpEvent>? onKeyUp = null, EventCallback<FocusInEvent>? onFocus = null, EventCallback<FocusOutEvent>? onBlur = null, Action<VisualElement>? onCreated = null, FiberEventBinding[]? events = null)
Parameters
classNamestringCSS-like utility class string. Multiple classes separated by spaces. Background, border, radius, padding, shadow and ring utilities style the field's box;
Documentation~/styling-variants.mdowns the list.valuestringCurrent text value (controlled).
onValueChangedAction<string>Handler invoked when the input text changes.
keystringKey used to disambiguate siblings at the same position.
namestringElement name assigned to UnityEngine.UIElements.VisualElement.name for query/debug.
labelstringLabel text shown next to the field.
isPasswordFieldbool?When true, masks the input as a password field.
enabledbool?When false, disables user input.
refCallbackFunc<VisualElement, Action>Callback invoked on mount with the created VisualElement; returned Action runs on unmount.
whileHoverClassstringUSS class toggled while the pointer hovers the element.
whileTapClassstringUSS class toggled while the pointer is pressed on the element.
whileFocusClassstringUSS class toggled while the element holds keyboard/UI focus.
dataIReadOnlyDictionary<string, string>data-* attribute map matched by
data-[...]variants.ariaIReadOnlyDictionary<string, string>aria-* attribute map matched by
aria-[...]variants.placeholderstringA short hint shown in the empty field (HTML
placeholder). An empty string declares an empty hint.maxLengthint?Maximum number of characters the field accepts, -1 for no limit (HTML
maxlength).isReadOnlybool?When true, the field cannot be edited (HTML
readonly).isDelayedbool?When true, the value is not updated per keystroke but on Enter, on the field losing focus, and on a later render taking the flag off.
multilinebool?When true, the field is multi-line (HTML
<textarea>).keyboardTypeTouchScreenKeyboardType?Written to the field's
keyboardType(HTMLinputmode).autoCorrectionbool?Written to the field's
autoCorrection(HTMLautocorrect).onSubmitAction<string>Handler invoked with the field's value when Enter commits a single-line field (a form's
onSubmitfrom Enter in its<input>). Not invoked in a multi-line field.onKeyDownEventCallback<KeyDownEvent>Handler invoked for each key pressed while the field holds focus, before the field takes the key; stopping the event's propagation keeps the key out of the field.
onKeyUpEventCallback<KeyUpEvent>Handler invoked for each key released while the field holds focus.
onFocusEventCallback<FocusInEvent>Handler invoked when focus enters the field from outside it.
onBlurEventCallback<FocusOutEvent>Handler invoked when focus leaves the field for somewhere outside it.
onCreatedAction<VisualElement>Callback invoked once when the TextField VisualElement is first created.
eventsFiberEventBinding[]Event bindings applied to the element, bound after the field's own handlers above (
Documentation~/react-migration.mdowns the rule). The array is read and never written.
Returns
- ElementNode
The created ElementNode representing this text field.
Remarks
placeholder, maxLength, isReadOnly,
isDelayed, multiline, keyboardType and
autoCorrection are undeclared when null rather than reset to a default;
Documentation~/react-migration.md owns what a null and a dropped one each do.