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

UsoButton is a custom button implementation, extending the Unity Button class, and is part of the GWG.UsoUIElements namespace. It provides additional functionality to the standard Button with the core Unity UI Elements framework. More...

Inheritance diagram for GWG.UsoUIElements.UsoButton:

Public Member Functions

 UsoButton ()
 Default constructor.
 UsoButton (Action btnAction)
 Default UI Toolkit Constructor that only needs an event handler.
 UsoButton (Background iconImage, Action clickEvent=null)
 Creates a new element with the specified icon image and click event handler.
 UsoButton (string fieldName)
 Creates an element with an assigned name.
 UsoButton (string fieldName, Action btnAction)
 Creates a element with an assigned name and event handler.
 UsoButton (string fieldName, Action btnAction, out UsoButton newField)
 Creates a element with an assigned name and event handler and an output field containing the new element.
 UsoButton (string fieldName, out UsoButton newField)
 Creates an element with an assigned name and an output field containing the new button.
 UsoButton (string fieldName, string fieldLabelText)
 Creates a element with an assigned name and label text.
 UsoButton (string fieldName, string fieldLabelText, Action btnAction)
 Creates a element with an assigned name, label text, and event handler.
 UsoButton (string fieldName, string fieldLabelText, Action btnAction, out UsoButton newField)
 Creates a element with an assigned name, label text, and event handler and an output field containing the new element.
 UsoButton (string fieldName, string fieldLabelText, Background iconImage)
 Creates a element with an assigned name, label text, and icon image.
 UsoButton (string fieldName, string fieldLabelText, Background iconImage, Action btnAction)
 Creates a element with an assigned name, label text, icon image, and event handler.
 UsoButton (string fieldName, string fieldLabelText, Background iconImage, Action btnAction, out UsoButton newFieldName)
 Creates a element with an assigned name, label text, icon image, and event handler and an output field containing the new element.
 UsoButton (string fieldName, string fieldLabelText, Background iconImage, out UsoButton newField)
 Creates a element with an assigned name, label text, and icon image and an output field containing the new element.
 UsoButton (string fieldName, string fieldLabelText, out UsoButton newField)
 Creates a element with an assigned name and label text and an output field containing the new element.
void ApplyBinding (string fieldBindingProp, string fieldBindingPath, BindingMode fieldBindingMode)
 ApplyBinding is a helper method that allows for more flexibility in applying the data binding.
UsoLineItem GetParentLineItem ()
 GetParentLineItem is a helper method that returns the parent UsoLineItem.
void InitElement (string fieldName=null)
 InitElement is a helper method that initializes the element in a standard way for all constructors using an optional field name.
void SetFieldStatus (FieldStatusTypes fieldStatus)
 SetFieldStatus is a helper method that sets the FieldStatus property.
void ShowFieldStatus (bool status)
 ShowFieldStatus is a helper method that sets the FieldStatusEnabled property.
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]
 FieldStatus is the validation feedback for the field and muct be one of the values in the FieldStatusTypes enum.
bool FieldStatusEnabled [get, private set]
 FieldStatusEnabled is a boolean value that determines whether the validation feedback is displayed. The default value is true.

Private Member Functions

void InitElement (string fieldName, string fieldLabelText)
 InitElement is a helper method that initializes the element in a standard way for all constructors using an optional field name and label text.

Private Attributes

FieldStatusTypes _fieldStatus
bool _fieldStatusEnabled = true

Static Private Attributes

const string DefaultBindProp = "value"
 Default Binding Property for this element, used when setting the data binding in the constructor. Can be overriden by using the ApplyBinding method which allows for more flexibility.
const string ElementClass = "uso-button"
 Default USS Style Class name for the element.
const string ElementValidationClass = "uso-field-validation"
 Default USS Field Validation Style Class name for the UsoUIElements Framework.

Detailed Description

UsoButton is a custom button implementation, extending the Unity Button class, and is part of the GWG.UsoUIElements namespace. It provides additional functionality to the standard Button with the core Unity UI Elements framework.

Additional functionality includes a standardized signature, support for field status management / validation response, and simplified data binding capabilities.

Constructor & Destructor Documentation

◆ UsoButton() [1/15]

GWG.UsoUIElements.UsoButton.UsoButton ( )

Default constructor.

◆ UsoButton() [2/15]

GWG.UsoUIElements.UsoButton.UsoButton ( Background iconImage,
Action clickEvent = null )

Creates a new element with the specified icon image and click event handler.

Parameters
iconImageImage to apply to the button
clickEventEvent handler when a click event happens

◆ UsoButton() [3/15]

GWG.UsoUIElements.UsoButton.UsoButton ( Action btnAction)

Default UI Toolkit Constructor that only needs an event handler.

◆ UsoButton() [4/15]

GWG.UsoUIElements.UsoButton.UsoButton ( string fieldName)

Creates an element with an assigned name.

Parameters
fieldNamename of the new button

◆ UsoButton() [5/15]

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

Creates an element with an assigned name and an output field containing the new button.

Parameters
fieldNameName of the new button
newFieldOut field containing the button

◆ UsoButton() [6/15]

GWG.UsoUIElements.UsoButton.UsoButton ( string fieldName,
Action btnAction )

Creates a element with an assigned name and event handler.

Parameters
fieldNameName for the new button
btnActionClick event handler

◆ UsoButton() [7/15]

GWG.UsoUIElements.UsoButton.UsoButton ( string fieldName,
Action btnAction,
out UsoButton newField )

Creates a element with an assigned name and event handler and an output field containing the new element.

Parameters
fieldNameName for the new button
btnActionClick event handler
newFieldOut field containing the new button

◆ UsoButton() [8/15]

GWG.UsoUIElements.UsoButton.UsoButton ( string fieldName,
string fieldLabelText )

Creates a element with an assigned name and label text.

Parameters
fieldNameName of the new element
fieldLabelTextText to display in the element

◆ UsoButton() [9/15]

GWG.UsoUIElements.UsoButton.UsoButton ( string fieldName,
string fieldLabelText,
out UsoButton newField )

Creates a element with an assigned name and label text and an output field containing the new element.

Parameters
fieldNameName of the new element
fieldLabelTextText to display in the element
newFieldOut field containing the new element

◆ UsoButton() [10/15]

GWG.UsoUIElements.UsoButton.UsoButton ( string fieldName,
string fieldLabelText,
Action btnAction )

Creates a element with an assigned name, label text, and event handler.

Parameters
fieldNameName of the new element
fieldLabelTextText to display in the new element
btnActionClick event handler for the new element

◆ UsoButton() [11/15]

GWG.UsoUIElements.UsoButton.UsoButton ( string fieldName,
string fieldLabelText,
Action btnAction,
out UsoButton newField )

Creates a element with an assigned name, label text, and event handler and an output field containing the new element.

Parameters
fieldNameName of the new element
fieldLabelTextText to display in the new element
btnActionClick event handler for the new element
newFieldOut field containing the new element

◆ UsoButton() [12/15]

GWG.UsoUIElements.UsoButton.UsoButton ( string fieldName,
string fieldLabelText,
Background iconImage )

Creates a element with an assigned name, label text, and icon image.

Parameters
fieldNameName of the new element
fieldLabelTextText to display in the new element
iconImageImage to display in the new element

◆ UsoButton() [13/15]

GWG.UsoUIElements.UsoButton.UsoButton ( string fieldName,
string fieldLabelText,
Background iconImage,
out UsoButton newField )

Creates a element with an assigned name, label text, and icon image and an output field containing the new element.

Parameters
fieldNameName of the new element
fieldLabelTextText to display in the new element
iconImageImage to display in the new element
newFieldOut field containing the new element

◆ UsoButton() [14/15]

GWG.UsoUIElements.UsoButton.UsoButton ( string fieldName,
string fieldLabelText,
Background iconImage,
Action btnAction )

Creates a element with an assigned name, label text, icon image, and event handler.

Parameters
fieldNameName of the new element
fieldLabelTextText to display in the new element
iconImageImage to display in the new element
btnActionClick event handler for the new element

◆ UsoButton() [15/15]

GWG.UsoUIElements.UsoButton.UsoButton ( string fieldName,
string fieldLabelText,
Background iconImage,
Action btnAction,
out UsoButton newFieldName )

Creates a element with an assigned name, label text, icon image, and event handler and an output field containing the new element.

Parameters
fieldNameName of the new element
fieldLabelTextText to display in the new element
iconImageImage to display in the new element
btnActionClick event handler for the new element
newFieldNameOut field containing the new element

Member Function Documentation

◆ ApplyBinding()

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

ApplyBinding is a helper method that allows for more flexibility in applying the data binding.

This method is used to apply a data binding to the element.
Any of the element properties can be bound to a data source using this method.

example uses a button but can apply to all Uso UI Elements

UsoButton btn = new UsoButton("btn");
btn.ApplyBinding("text", "myData.myField", BindingMode.OneWay);
UsoButton()
Default constructor.
Definition UsoButton.cs:202
void ApplyBinding(string fieldBindingProp, string fieldBindingPath, BindingMode fieldBindingMode)
ApplyBinding is a helper method that allows for more flexibility in applying the data binding.
Definition UsoButton.cs:139

The Example above will bind the 'text' property of the UsoButton to the 'myField' property path within the 'myData' object in readonly mode causing the value stores in the data source to be displayed in the button.

Parameters
fieldBindingPropProperty of the button you want to bind to as a string value
fieldBindingPathData path within the assigned datasource that you wish to bind the property to.
fieldBindingModeBinding mode to use, can be read-only, write-only, or read/write
See also
BindingMode, PropertyPath

Implements GWG.UsoUIElements.IUsoUiElement.

◆ GetParentLineItem()

UsoLineItem GWG.UsoUIElements.UsoButton.GetParentLineItem ( )

GetParentLineItem is a helper method that returns the parent UsoLineItem.

This method is used to get the parent UsoLineItem of the UsoButton.
When fully implementing this framework, the hierarchy would be similar to:

- - UsoRowElement / UsoColumnElement
- - - UsoButton / UsoTextField / UsoDropDown / etc
A custom line item container element that extends Unity's VisualElement with USO UI framework functio...
Definition UsoLineItem.cs:26
A custom row layout container element that extends Unity's VisualElement with USO UI framework functi...
Definition UsoRowElement.cs:23
A custom text field control that extends Unity's TextField with USO UI framework functionality....
Definition UsoTextField.cs:22
A custom UI display section container element that extends Unity's VisualElement with USO UI framewor...
Definition UsoUiDisplaySection.cs:28
Returns

◆ InitElement() [1/2]

void GWG.UsoUIElements.UsoButton.InitElement ( string fieldName,
string fieldLabelText )
private

InitElement is a helper method that initializes the element in a standard way for all constructors using an optional field name and label text.

Parameters
fieldName
fieldLabelText

◆ InitElement() [2/2]

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

InitElement is a helper method that initializes the element in a standard way for all constructors using an optional field name.

Parameters
fieldName

Implements GWG.UsoUIElements.IUsoUiElement.

◆ SetFieldStatus()

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

SetFieldStatus is a helper method that sets the FieldStatus property.

Parameters
fieldStatus

Implements GWG.UsoUIElements.IUsoUiElement.

◆ ShowFieldStatus()

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

ShowFieldStatus is a helper method that sets the FieldStatusEnabled property.

Parameters
status

Implements GWG.UsoUIElements.IUsoUiElement.

Member Data Documentation

◆ _fieldStatus

FieldStatusTypes GWG.UsoUIElements.UsoButton._fieldStatus
private

◆ _fieldStatusEnabled

bool GWG.UsoUIElements.UsoButton._fieldStatusEnabled = true
private

◆ DefaultBindProp

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

Default Binding Property for this element, used when setting the data binding in the constructor. Can be overriden by using the ApplyBinding method which allows for more flexibility.

◆ ElementClass

const string GWG.UsoUIElements.UsoButton.ElementClass = "uso-button"
staticprivate

Default USS Style Class name for the element.

◆ ElementValidationClass

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

Default USS Field Validation Style Class name for the UsoUIElements Framework.

Property Documentation

◆ FieldStatus

FieldStatusTypes GWG.UsoUIElements.UsoButton.FieldStatus
getprivate set

FieldStatus is the validation feedback for the field and muct be one of the values in the FieldStatusTypes enum.

This property is used to display the validation feedback for the field. The default value is FieldStatusTypes.None. The FieldStatusTypes enum provides the following values:

  • None
  • Valid
  • Invalid

The

See also
FieldStatusEnabled

must be true for the validation to be displayed.

See also
FieldStatusTypes

Implements GWG.UsoUIElements.IUsoUiElement.

◆ FieldStatusEnabled

bool GWG.UsoUIElements.UsoButton.FieldStatusEnabled
getprivate set

FieldStatusEnabled is a boolean value that determines whether the validation feedback is displayed. The default value is true.

The FieldStatusEnabled property is used to determine whether the validation feedback is displayed. The default value is true.

See also
FieldStatus

Implements GWG.UsoUIElements.IUsoUiElement.