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

A custom help box control that extends Unity's HelpBox 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.UsoHelpBox:

Public Member Functions

 UsoHelpBox ()
 Initializes a new instance of the UsoHelpBox class with default settings. Creates an empty help box with USO framework integration enabled.
 UsoHelpBox (string fieldName)
 Initializes a new instance of the UsoHelpBox class with the specified field name. Creates an empty help box with custom identification for binding and reference purposes.
 UsoHelpBox (string fieldName, out UsoHelpBox newField)
 Initializes a new instance of the UsoHelpBox class with field name and returns a reference. Creates an empty help box with custom identification and provides an out parameter for immediate access.
 UsoHelpBox (string fieldName, string message, HelpBoxMessageType helpType)
 Initializes a new instance of the UsoHelpBox class with field name, message, and help type. Creates a fully configured help box with custom identification, content, and visual styling.
 UsoHelpBox (string fieldName, string message, HelpBoxMessageType helpType, out UsoHelpBox newField)
 Initializes a new instance of the UsoHelpBox class with field name, message, help type, and returns a reference. Creates a fully configured help box and provides an out parameter for immediate access to the created instance.
 UsoHelpBox (string message, HelpBoxMessageType helpType, out UsoHelpBox newField)
 Initializes a new instance of the UsoHelpBox class with message, help type, and returns a reference. Creates a help box with custom content and provides an out parameter for immediate access to the created instance.
 UsoHelpBox (string message, HelpBoxMessageType helpType=HelpBoxMessageType.None)
 Initializes a new instance of the UsoHelpBox class with the specified message and help type. Creates a help box with custom content and visual styling based on the message type.
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.
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 and configures layout properties.
void SetFieldStatus (FieldStatusTypes fieldStatus)
 Updates the field's status type, which affects its visual appearance and automatically maps to the appropriate HelpBox message type. The status change is automatically reflected in the UI through both the FieldStatus property and the HelpBox message type.
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 and message type changes.
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 Attributes

FieldStatusTypes _fieldStatus
bool _fieldStatusEnabled = true

Static Private Attributes

const string DefaultBindProp = "text"
 Default binding property used when applying data bindings to this field. Binds to the 'text' property which controls the displayed message content.
const string ElementClass = "uso-help-box"
 CSS class name applied to all UsoHelpBox 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 help box control that extends Unity's HelpBox 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 that automatically map to HelpBox message types, automatic data binding, and custom styling through CSS classes. The control is configured with flex-shrink: 0 by default to maintain its size. Field status types are automatically converted to appropriate HelpBox message types for visual consistency.

Constructor & Destructor Documentation

◆ UsoHelpBox() [1/7]

GWG.UsoUIElements.UsoHelpBox.UsoHelpBox ( string message,
HelpBoxMessageType helpType = HelpBoxMessageType::None )

Initializes a new instance of the UsoHelpBox class with the specified message and help type. Creates a help box with custom content and visual styling based on the message type.

Parameters
messageThe text message to display in the help box.
helpTypeThe type of help box that determines its visual appearance and icon. Default is None.

◆ UsoHelpBox() [2/7]

GWG.UsoUIElements.UsoHelpBox.UsoHelpBox ( string message,
HelpBoxMessageType helpType,
out UsoHelpBox newField )

Initializes a new instance of the UsoHelpBox class with message, help type, and returns a reference. Creates a help box with custom content and provides an out parameter for immediate access to the created instance.

Parameters
messageThe text message to display in the help box.
helpTypeThe type of help box that determines its visual appearance and icon.
newFieldOutput parameter that receives a reference to the newly created help box.

◆ UsoHelpBox() [3/7]

GWG.UsoUIElements.UsoHelpBox.UsoHelpBox ( string fieldName)

Initializes a new instance of the UsoHelpBox class with the specified field name. Creates an empty help box with custom identification for binding and reference purposes.

Parameters
fieldNameThe name to assign to this help box element.

◆ UsoHelpBox() [4/7]

GWG.UsoUIElements.UsoHelpBox.UsoHelpBox ( string fieldName,
out UsoHelpBox newField )

Initializes a new instance of the UsoHelpBox class with field name and returns a reference. Creates an empty help box with custom identification and provides an out parameter for immediate access.

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

◆ UsoHelpBox() [5/7]

GWG.UsoUIElements.UsoHelpBox.UsoHelpBox ( string fieldName,
string message,
HelpBoxMessageType helpType )

Initializes a new instance of the UsoHelpBox class with field name, message, and help type. Creates a fully configured help box with custom identification, content, and visual styling.

Parameters
fieldNameThe name to assign to this help box element.
messageThe text message to display in the help box.
helpTypeThe type of help box that determines its visual appearance and icon.

◆ UsoHelpBox() [6/7]

GWG.UsoUIElements.UsoHelpBox.UsoHelpBox ( string fieldName,
string message,
HelpBoxMessageType helpType,
out UsoHelpBox newField )

Initializes a new instance of the UsoHelpBox class with field name, message, help type, and returns a reference. Creates a fully configured help box and provides an out parameter for immediate access to the created instance.

Parameters
fieldNameThe name to assign to this help box element.
messageThe text message to display in the help box.
helpTypeThe type of help box that determines its visual appearance and icon.
newFieldOutput parameter that receives a reference to the newly created help box.

◆ UsoHelpBox() [7/7]

GWG.UsoUIElements.UsoHelpBox.UsoHelpBox ( )

Initializes a new instance of the UsoHelpBox class with default settings. Creates an empty help box with USO framework integration enabled.

Member Function Documentation

◆ ApplyBinding()

void GWG.UsoUIElements.UsoHelpBox.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.

◆ GetParentLineItem()

UsoLineItem GWG.UsoUIElements.UsoHelpBox.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()

void GWG.UsoUIElements.UsoHelpBox.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 and configures layout properties.

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

Implements GWG.UsoUIElements.IUsoUiElement.

◆ SetFieldStatus()

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

Updates the field's status type, which affects its visual appearance and automatically maps to the appropriate HelpBox message type. The status change is automatically reflected in the UI through both the FieldStatus property and the HelpBox message type.

Parameters
fieldStatusThe new field status type to apply. Maps to corresponding HelpBoxMessageType values.

Status mapping:

  • Error → HelpBoxMessageType.Error
  • Warning → HelpBoxMessageType.Warning
  • Info → HelpBoxMessageType.Info
  • All other values → HelpBoxMessageType.None

Implements GWG.UsoUIElements.IUsoUiElement.

◆ ShowFieldStatus()

void GWG.UsoUIElements.UsoHelpBox.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.UsoHelpBox._fieldStatus
private

◆ _fieldStatusEnabled

bool GWG.UsoUIElements.UsoHelpBox._fieldStatusEnabled = true
private

◆ DefaultBindProp

const string GWG.UsoUIElements.UsoHelpBox.DefaultBindProp = "text"
staticprivate

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

◆ ElementClass

const string GWG.UsoUIElements.UsoHelpBox.ElementClass = "uso-help-box"
staticprivate

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

◆ ElementValidationClass

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

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

Property Documentation

◆ FieldStatus

FieldStatusTypes GWG.UsoUIElements.UsoHelpBox.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 and message type changes.

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

Implements GWG.UsoUIElements.IUsoUiElement.

◆ FieldStatusEnabled

bool GWG.UsoUIElements.UsoHelpBox.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.