Window Framework for UI Toolkit v2.0.x
GWG.Extensions.SlideToggleControl Class Reference

Represents a custom UI component that functions as a toggle control with sliding animation.
Original file from the Unity documentation with only minor compatability modifications made. More...

Inheritance diagram for GWG.Extensions.SlideToggleControl:
Collaboration diagram for GWG.Extensions.SlideToggleControl:

Public Member Functions

 SlideToggleControl ()
 Creates A custom UI control representing a Toggle element with a sliding animation but no Label, designed to manage a boolean value in a visually interactive way.
 SlideToggleControl (string label)
 A custom UI control that visually represents a Toggle element with a sliding animation and Label, It serves as a container for its child control, providing an interactive element for enabling or disabling a boolean value.
override void SetValueWithoutNotify (bool newValue)
 Sets the boolean without dispatching this field's ChangeEvent.

Private Member Functions

void ToggleValue ()
 Toggles the current value of the SlideToggleControl between true and false. Updates the visual representation of the toggle to reflect the changed state.

Static Private Member Functions

static void OnClick (ClickEvent evt)
static void OnKeydownEvent (KeyDownEvent evt)
static void OnSubmit (NavigationSubmitEvent evt)

Private Attributes

VisualElement m_Input
VisualElement m_Knob
VisualElement m_Label

Static Private Attributes

const string InputCheckedUssClassName = "slide-toggle__input--checked"
const string InputKnobUssClassName = "slide-toggle__input-knob"
const string InputUssClassName = "slide-toggle__input"
const string LabelUssClassName = "slide-toggle__label"
const string USSClassName = "slide-toggle"

Detailed Description

Represents a custom UI component that functions as a toggle control with sliding animation.
Original file from the Unity documentation with only minor compatability modifications made.

A UI Toolkit BaseField<bool> with a styled track and knob. It is not derived from System.Boolean and does not implement preference persistence itself. The configured application/editor USS supplies animation and appearance; construction adds classes only. Click and NavigationSubmit toggle value. KeyDown handles Enter/Return/Space outside player panels; player panels rely on NavigationSubmit to avoid double toggling. Use value for ordinary ChangeEvent notification and SetValueWithoutNotify for silent synchronization. Both update the checked class and current portable control styling.

Constructor & Destructor Documentation

◆ SlideToggleControl() [1/2]

GWG.Extensions.SlideToggleControl.SlideToggleControl ( )
inline

Creates A custom UI control representing a Toggle element with a sliding animation but no Label, designed to manage a boolean value in a visually interactive way.

The control derives from BaseField<bool> and provides a stylizedand interactive interface for enabling or disabling a boolean state. It includes a sliding knob and supports input events such as clicking, KeyValue presses, and navigation-based submissions, offering a user-friendly functionality. The control is styled through specific USS classes which can be customized further.

Here is the caller graph for this function:

◆ SlideToggleControl() [2/2]

GWG.Extensions.SlideToggleControl.SlideToggleControl ( string label)
inline

A custom UI control that visually represents a Toggle element with a sliding animation and Label, It serves as a container for its child control, providing an interactive element for enabling or disabling a boolean value.

This control derives from BaseField<bool> and is stylized to align content in a flexible and user-friendly manner. Users can activate or deactivate the toggle through multiple input methods: clicking, pressing a KeyValue, or submitting navigation input. The control includes custom styling and a knob element to enhance visualization.

Parameters
labelOptional field caption; null omits a meaningful caption.

Construction wires field gestures and CSS classes, not preference persistence. Supplied stylesheet controls visual animation; value notifications follow BaseField.

Here is the call graph for this function:

Member Function Documentation

◆ OnClick()

void GWG.Extensions.SlideToggleControl.OnClick ( ClickEvent evt)
inlinestaticprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnKeydownEvent()

void GWG.Extensions.SlideToggleControl.OnKeydownEvent ( KeyDownEvent evt)
inlinestaticprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnSubmit()

void GWG.Extensions.SlideToggleControl.OnSubmit ( NavigationSubmitEvent evt)
inlinestaticprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetValueWithoutNotify()

override void GWG.Extensions.SlideToggleControl.SetValueWithoutNotify ( bool newValue)
inline

Sets the boolean without dispatching this field's ChangeEvent.

Parameters
newValueNew checked state; does not mean control enabled/disabled.

Updates the input's checked class and invokes existing portable-control style refresh. This is not a guarantee that every observer is silent; it does not persist a preference or bypass the application's settings handler through a separate authority.

Here is the call graph for this function:

◆ ToggleValue()

void GWG.Extensions.SlideToggleControl.ToggleValue ( )
inlineprivate

Toggles the current value of the SlideToggleControl between true and false. Updates the visual representation of the toggle to reflect the changed state.

This method is used internally by event handlers such as ClickEvent, KeyDownEvent, and NavigationSubmitEvent to alter the toggle state in response to user interactions. It flips the boolean value and adjusts the toggle's appearance accordingly.

Field Documentation

◆ InputCheckedUssClassName

const string GWG.Extensions.SlideToggleControl.InputCheckedUssClassName = "slide-toggle__input--checked"
staticprivate

◆ InputKnobUssClassName

const string GWG.Extensions.SlideToggleControl.InputKnobUssClassName = "slide-toggle__input-knob"
staticprivate

◆ InputUssClassName

const string GWG.Extensions.SlideToggleControl.InputUssClassName = "slide-toggle__input"
staticprivate

◆ LabelUssClassName

const string GWG.Extensions.SlideToggleControl.LabelUssClassName = "slide-toggle__label"
staticprivate

◆ m_Input

VisualElement GWG.Extensions.SlideToggleControl.m_Input
private

◆ m_Knob

VisualElement GWG.Extensions.SlideToggleControl.m_Knob
private

◆ m_Label

VisualElement GWG.Extensions.SlideToggleControl.m_Label
private

◆ USSClassName

const string GWG.Extensions.SlideToggleControl.USSClassName = "slide-toggle"
staticprivate