UsoUIElements 0.1.0
Data Centric implimentation of Unity's UI Elements (UI Toolkit)
Loading...
Searching...
No Matches
GWG.UsoUIElements.UsoTextField Class Reference

A custom text field control that extends Unity's TextField with USO UI framework functionality. Provides enhanced styling, field validation, data binding capabilities, and integration with the USO UI system. More...

Inheritance diagram for GWG.UsoUIElements.UsoTextField:

Public Member Functions

 UsoTextField ()
 Initializes a new instance of the UsoTextField class with default settings. Creates an empty text field with USO framework integration enabled.
 UsoTextField (string fieldName, string bindingPath, BindingMode bindingMode)
 Initializes a new instance of the UsoTextField class with field name and data binding configuration. Creates a text field with custom identification and automatic data binding for value synchronization.
 UsoTextField (string fieldName, string bindingPath, BindingMode bindingMode, out UsoTextField newFieldName)
 Initializes a new instance of the UsoTextField class with field name, data binding configuration, and returns a reference. Creates a text field with custom identification, automatic data binding, and provides an out parameter for immediate access.
 UsoTextField (string fieldName, string labelText, out UsoTextField newFieldName)
 Initializes a new instance of the UsoTextField class with field name, label text, and returns a reference. Creates a text field with custom identification, display label, and provides an out parameter for immediate access.
 UsoTextField (string fieldName, string labelText, string bindingPath, BindingMode bindingMode)
 Initializes a new instance of the UsoTextField class with field name, label text, and data binding configuration. Creates a fully configured text field with custom identification, display label, and automatic data binding for value synchronization.
 UsoTextField (string fieldName, string labelText, string bindingPath, BindingMode bindingMode, Object fieldDatasource)
 Initializes a new instance of the UsoTextField class with complete configuration including custom data source. Creates a fully configured text field with custom identification, display label, automatic data binding, and explicit data source assignment.
 UsoTextField (string fieldName, string labelText, string bindingPath, BindingMode bindingMode, out UsoTextField newFieldName)
 Initializes a new instance of the UsoTextField class with field name, label text, data binding, and returns a reference. Creates a fully configured text field with custom identification, display label, automatic data binding, and immediate access to the created instance.
 UsoTextField (string fieldName, string labelText=null)
 Initializes a new instance of the UsoTextField class with field name and optional label text. Creates a text field with custom identification and optional display labeling for user interface clarity.
void ApplyBinding (string fieldBindingProp, string fieldBindingPath, BindingMode fieldBindingMode)
 Applies data binding to the specified property of this control using Unity's data binding system. Configures the binding with the provided path and mode for automatic data synchronization.
void ClearData ()
 Clears the text field's content by setting the value to an empty string. This method provides a convenient way to reset the field's data programmatically.
UsoLineItem GetParentLineItem ()
 Retrieves the first ancestor UsoLineItem control in the visual tree hierarchy. This is useful for accessing parent container functionality and maintaining proper UI structure.
void InitElement (string fieldName=null)
 Initializes the USO UI element with the specified field name and applies necessary styling classes. This method sets up the basic USO framework integration for the control.
void SetFieldStatus (FieldStatusTypes fieldStatus)
 Updates the field's status type, which affects its visual appearance and validation state. The status change is automatically reflected in the UI through the FieldStatus property.
void ShowFieldStatus (bool status)
 Controls the visibility and functionality of the field status/validation system. When disabled, removes validation-related styling from the control.
Public Member Functions inherited from GWG.UsoUIElements.IUsoUiElement
void AddToClassList (string className)
 Adds the specified CSS class name to this element's class list. This method is inherited from Unity's VisualElement and enables dynamic styling modifications.
void ClearBindings ()
 Removes all data binding configurations from this element. This method is inherited from Unity's VisualElement and provides cleanup functionality for data bindings.
void RemoveFromClassList (string className)
 Removes the specified CSS class name from this element's class list. This method is inherited from Unity's VisualElement and provides dynamic styling capabilities.

Properties

FieldStatusTypes FieldStatus [get, private set]
 Gets the current field status type, which determines the visual state and validation feedback. This property is automatically reflected in the UI through CSS class modifications.
bool FieldStatusEnabled [get, private set]
 Gets or sets whether field status/validation functionality is enabled for this control. When enabled, adds validation CSS class for styling. When disabled, removes validation styling.

Private Member Functions

void InitElement (string fieldName, out UsoTextField newField)
 Private initialization method that sets up the element and provides a reference through an out parameter. This overload provides convenient setup for constructors that need immediate reference access to the created instance.
void InitElement (string fieldName, string fieldBindingPath, BindingMode fieldBindingMode)
 Private initialization method that combines element setup with data binding configuration. This overload provides convenient setup for constructors that need both element initialization and binding.
void InitElement (string fieldName, string fieldBindingPath, BindingMode fieldBindingMode, out UsoTextField newFieldName)
 Private initialization method that combines element setup with data binding configuration and reference output. This overload provides convenient setup for constructors that need element initialization, binding, and immediate reference access.

Private Attributes

FieldStatusTypes _fieldStatus
bool _fieldStatusEnabled = true

Static Private Attributes

const string DefaultBindProp = "value"
 Default binding property used when applying data bindings to this field. Binds to the 'value' property which controls the text content of the field.
const string ElementClass = "uso-text-field"
 CSS class name applied to all UsoTextField instances for styling purposes.
const string ElementValidationClass = "uso-field-validation"
 CSS class name applied when field validation/status functionality is enabled.

Detailed Description

A custom text field control that extends Unity's TextField with USO UI framework functionality. Provides enhanced styling, field validation, data binding capabilities, and integration with the USO UI system.

This control implements the IUsoUiElement interface to provide consistent behavior across the USO UI framework. It supports field status indicators, automatic data binding for string values, and custom styling through CSS classes. The control includes additional functionality such as data clearing capabilities and supports various constructor overloads for different initialization scenarios including labeling, data binding configuration, and custom data source assignment. This is one of the most commonly used input controls in the USO framework for text-based user input.

Constructor & Destructor Documentation

◆ UsoTextField() [1/8]

GWG.UsoUIElements.UsoTextField.UsoTextField ( string fieldName,
string labelText,
out UsoTextField newFieldName )

Initializes a new instance of the UsoTextField class with field name, label text, and returns a reference. Creates a text field with custom identification, display label, and provides an out parameter for immediate access.

Parameters
fieldNameThe name to assign to this text field element.
labelTextThe label text to display alongside the text field control.
newFieldNameOutput parameter that receives a reference to the newly created text field.

◆ UsoTextField() [2/8]

GWG.UsoUIElements.UsoTextField.UsoTextField ( string fieldName,
string labelText = null )

Initializes a new instance of the UsoTextField class with field name and optional label text. Creates a text field with custom identification and optional display labeling for user interface clarity.

Parameters
fieldNameThe name to assign to this text field element.
labelTextOptional label text to display alongside the text field control. Default is null.

◆ UsoTextField() [3/8]

GWG.UsoUIElements.UsoTextField.UsoTextField ( string fieldName,
string labelText,
string bindingPath,
BindingMode bindingMode,
out UsoTextField newFieldName )

Initializes a new instance of the UsoTextField class with field name, label text, data binding, and returns a reference. Creates a fully configured text field with custom identification, display label, automatic data binding, and immediate access to the created instance.

Parameters
fieldNameThe name to assign to this text field element.
labelTextThe label text to display alongside the text field control.
bindingPathThe path to the data source property for automatic value binding.
bindingModeThe binding mode that controls data flow between source and target.
newFieldNameOutput parameter that receives a reference to the newly created text field.

◆ UsoTextField() [4/8]

GWG.UsoUIElements.UsoTextField.UsoTextField ( string fieldName,
string bindingPath,
BindingMode bindingMode,
out UsoTextField newFieldName )

Initializes a new instance of the UsoTextField class with field name, data binding configuration, and returns a reference. Creates a text field with custom identification, automatic data binding, and provides an out parameter for immediate access.

Parameters
fieldNameThe name to assign to this text field element.
bindingPathThe path to the data source property for automatic value binding.
bindingModeThe binding mode that controls data flow between source and target.
newFieldNameOutput parameter that receives a reference to the newly created text field.

◆ UsoTextField() [5/8]

GWG.UsoUIElements.UsoTextField.UsoTextField ( string fieldName,
string bindingPath,
BindingMode bindingMode )

Initializes a new instance of the UsoTextField class with field name and data binding configuration. Creates a text field with custom identification and automatic data binding for value synchronization.

Parameters
fieldNameThe name to assign to this text field element.
bindingPathThe path to the data source property for automatic value binding.
bindingModeThe binding mode that controls data flow between source and target.

◆ UsoTextField() [6/8]

GWG.UsoUIElements.UsoTextField.UsoTextField ( string fieldName,
string labelText,
string bindingPath,
BindingMode bindingMode )

Initializes a new instance of the UsoTextField class with field name, label text, and data binding configuration. Creates a fully configured text field with custom identification, display label, and automatic data binding for value synchronization.

Parameters
fieldNameThe name to assign to this text field element.
labelTextThe label text to display alongside the text field control.
bindingPathThe path to the data source property for automatic value binding.
bindingModeThe binding mode that controls data flow between source and target.

◆ UsoTextField() [7/8]

GWG.UsoUIElements.UsoTextField.UsoTextField ( string fieldName,
string labelText,
string bindingPath,
BindingMode bindingMode,
Object fieldDatasource )

Initializes a new instance of the UsoTextField class with complete configuration including custom data source. Creates a fully configured text field with custom identification, display label, automatic data binding, and explicit data source assignment.

Parameters
fieldNameThe name to assign to this text field element.
labelTextThe label text to display alongside the text field control.
bindingPathThe path to the data source property for automatic value binding.
bindingModeThe binding mode that controls data flow between source and target.
fieldDatasourceThe Unity Object to use as the data source for binding operations.

◆ UsoTextField() [8/8]

GWG.UsoUIElements.UsoTextField.UsoTextField ( )

Initializes a new instance of the UsoTextField class with default settings. Creates an empty text field with USO framework integration enabled.

Member Function Documentation

◆ ApplyBinding()

void GWG.UsoUIElements.UsoTextField.ApplyBinding ( string fieldBindingProp,
string fieldBindingPath,
BindingMode fieldBindingMode )

Applies data binding to the specified property of this control using Unity's data binding system. Configures the binding with the provided path and mode for automatic data synchronization.

Parameters
fieldBindingPropThe property name on this control to bind to.
fieldBindingPathThe path to the data source property to bind from.
fieldBindingModeThe binding mode that determines how data flows between source and target.
Exceptions
ExceptionThrown when binding setup fails. Original exception is preserved and re-thrown.

Implements GWG.UsoUIElements.IUsoUiElement.

◆ ClearData()

void GWG.UsoUIElements.UsoTextField.ClearData ( )

Clears the text field's content by setting the value to an empty string. This method provides a convenient way to reset the field's data programmatically.

◆ GetParentLineItem()

UsoLineItem GWG.UsoUIElements.UsoTextField.GetParentLineItem ( )

Retrieves the first ancestor UsoLineItem control in the visual tree hierarchy. This is useful for accessing parent container functionality and maintaining proper UI structure.

Returns
The parent UsoLineItem if found; otherwise, null.

◆ InitElement() [1/4]

void GWG.UsoUIElements.UsoTextField.InitElement ( string fieldName,
out UsoTextField newField )
private

Private initialization method that sets up the element and provides a reference through an out parameter. This overload provides convenient setup for constructors that need immediate reference access to the created instance.

Parameters
fieldNameThe name to assign to this text field element.
newFieldOutput parameter that receives a reference to the newly created text field.

◆ InitElement() [2/4]

void GWG.UsoUIElements.UsoTextField.InitElement ( string fieldName,
string fieldBindingPath,
BindingMode fieldBindingMode )
private

Private initialization method that combines element setup with data binding configuration. This overload provides convenient setup for constructors that need both element initialization and binding.

Parameters
fieldNameThe name to assign to this text field element.
fieldBindingPathThe path to the data source property for automatic value binding.
fieldBindingModeThe binding mode that controls data flow between source and target.

◆ InitElement() [3/4]

void GWG.UsoUIElements.UsoTextField.InitElement ( string fieldName,
string fieldBindingPath,
BindingMode fieldBindingMode,
out UsoTextField newFieldName )
private

Private initialization method that combines element setup with data binding configuration and reference output. This overload provides convenient setup for constructors that need element initialization, binding, and immediate reference access.

Parameters
fieldNameThe name to assign to this text field element.
fieldBindingPathThe path to the data source property for automatic value binding.
fieldBindingModeThe binding mode that controls data flow between source and target.
newFieldNameOutput parameter that receives a reference to the newly created text field.

◆ InitElement() [4/4]

void GWG.UsoUIElements.UsoTextField.InitElement ( string fieldName = null)

Initializes the USO UI element with the specified field name and applies necessary styling classes. This method sets up the basic USO framework integration for the control.

Parameters
fieldNameOptional name to assign to the element. If null, no name is set.

Implements GWG.UsoUIElements.IUsoUiElement.

◆ SetFieldStatus()

void GWG.UsoUIElements.UsoTextField.SetFieldStatus ( FieldStatusTypes fieldStatus)

Updates the field's status type, which affects its visual appearance and validation state. The status change is automatically reflected in the UI through the FieldStatus property.

Parameters
fieldStatusThe new field status type to apply.

Implements GWG.UsoUIElements.IUsoUiElement.

◆ ShowFieldStatus()

void GWG.UsoUIElements.UsoTextField.ShowFieldStatus ( bool status)

Controls the visibility and functionality of the field status/validation system. When disabled, removes validation-related styling from the control.

Parameters
statusTrue to enable field status functionality; false to disable it.

Implements GWG.UsoUIElements.IUsoUiElement.

Member Data Documentation

◆ _fieldStatus

FieldStatusTypes GWG.UsoUIElements.UsoTextField._fieldStatus
private

◆ _fieldStatusEnabled

bool GWG.UsoUIElements.UsoTextField._fieldStatusEnabled = true
private

◆ DefaultBindProp

const string GWG.UsoUIElements.UsoTextField.DefaultBindProp = "value"
staticprivate

Default binding property used when applying data bindings to this field. Binds to the 'value' property which controls the text content of the field.

◆ ElementClass

const string GWG.UsoUIElements.UsoTextField.ElementClass = "uso-text-field"
staticprivate

CSS class name applied to all UsoTextField instances for styling purposes.

◆ ElementValidationClass

const string GWG.UsoUIElements.UsoTextField.ElementValidationClass = "uso-field-validation"
staticprivate

CSS class name applied when field validation/status functionality is enabled.

Property Documentation

◆ FieldStatus

FieldStatusTypes GWG.UsoUIElements.UsoTextField.FieldStatus
getprivate set

Gets the current field status type, which determines the visual state and validation feedback. This property is automatically reflected in the UI through CSS class modifications.

The current FieldStatusTypes value indicating the field's validation state.

Implements GWG.UsoUIElements.IUsoUiElement.

◆ FieldStatusEnabled

bool GWG.UsoUIElements.UsoTextField.FieldStatusEnabled
getprivate set

Gets or sets whether field status/validation functionality is enabled for this control. When enabled, adds validation CSS class for styling. When disabled, removes validation styling.

True if field status functionality is enabled; otherwise, false. Default is true.

Implements GWG.UsoUIElements.IUsoUiElement.