UDreamToggle
A toggle whose hierarchy is code, not an asset.
Inherits from UDreamUIControl.
Declared in Public/Controls/DreamToggle.h.
A toggle whose hierarchy is code, not an asset.
The same four nodes BP_Toggle has -- a box, a tick inside it, a label beside it -- built in NativeOnInitialized instead of instanced from a template. What that buys is that the control cannot be half-built: BP_Button shipped for months with no UIButton on it and nothing said so, and a class that always adds its own behaviour cannot have that happen to it.
What it costs is the tree nobody can open. Everything an author would otherwise have reached into the hierarchy to change has to be a property here, which is what FDreamToggleStyle is, and the moment a project wants all its toggles to agree that stops being enough.
It composes into .dui with no language change at all, because a class path is already a node tag:
Native.Toggle Mute {
Style.TickChecked = #FF3355
OnToggleChanged -> HandleMuteProperties
| Name | Type | Category | In the details panel | From Blueprint | Description |
|---|---|---|---|---|---|
Style | FDreamToggleStyle | Toggle | yes | GetStyle / SetStyle | This instance's own look. The project sheet wins while StyleSource says so AND a sheet actually exists; with no sheet in the project this IS the look in effect -- which is why it stays editable instead of being gated on the enum: the old edit condition greyed the exact values that were driving the control. |
ClickMethod | EDreamUIClickMethod | Toggle | yes | GetClickMethod / SetClickMethod | WHEN the tick flips, per input kind -- UMG's three enums, surfaced at the control exactly as UDreamButton surfaces them and for the same reason: they live on the selectable underneath, and a control that never stated them left every check box on the desktop's DownAndUp. |
TouchMethod | EDreamUITouchMethod | Toggle | yes | GetTouchMethod / SetTouchMethod | |
PressMethod | EDreamUIPressMethod | Toggle | yes | GetPressMethod / SetPressMethod | |
AcceptedMouseButtons | int32 | Toggle | yes | GetAcceptedMouseButtons / SetAcceptedMouseButtons | WHICH mouse buttons press and flip this check box -- a bitmask over EDreamUIMouseButtonType, the left button alone by default, which is UMG's rule: SCheckBox toggles on the left button and nothing else, so a right click neither presses nor flips it and goes on to whatever is behind. |
CheckedState | EDreamCheckState | Toggle | yes | GetCheckedState / SetCheckedState | The authored state, in UMG's spelling and with UMG's third value. A click moves it the way UMG's check box does: Unchecked to Checked, and Checked or Undetermined to Unchecked -- a mixed state is cleared by a click, never ticked. A property rather than the getter/setter pair alone, because the pair alone is invisible: .dui writes properties, the designer lists properties, and a binding resolves a property -- so a knob that exists only as two UFUNCTIONs is a knob nothing outside C++ can turn. |
bIsOn | bool | Toggle | yes | GetIsOn / SetIsOn | The compatibility spelling: CheckedState as a bool. Checked mirrors true; Unchecked and Undetermined mirror false. Kept as a property because existing .dui two-way-binds it (bIsOn <-> ...) and a binding resolves a property; kept coherent with CheckedState through every path (authored push, user click, programmatic set). New code speaks CheckedState. |
BoxNode | TObjectPtr<UDreamWidget> | Toggle | - | read only | The parts, in the shape the rest of the framework expects to find them. |
TickNode | TObjectPtr<UDreamWidget> | Toggle | - | read only | |
MarkNode | TObjectPtr<UDreamWidget> | Toggle | - | read only | The image mark -- active only while the current state's brush holds an image. |
ToggleBehaviour | TObjectPtr<UUIToggle> | Toggle | - | read only |
Functions
| Function | Kind | Description |
|---|---|---|
int32 GetAcceptedMouseButtons() | pure | Get Accepted Mouse Buttons |
EDreamCheckState GetCheckedState() | pure | The full state. The behaviour is the truth for the two states it can hold; Undetermined is the control's own and reads from here. |
EDreamUIClickMethod GetClickMethod() | pure | Get Click Method |
bool GetIsOn() | pure | The compatibility spelling of IsChecked(): the behaviour's bool once it exists, bIsOn before. |
EDreamUIPressMethod GetPressMethod() | pure | Get Press Method |
FDreamToggleStyle GetStyle() | pure | Get Style |
EDreamUITouchMethod GetTouchMethod() | pure | Get Touch Method |
bool IsChecked() | pure | UMG's convenience: exactly GetCheckedState() == Checked. |
bool IsPressed() | pure | Whether a pointer is holding the box down -- UMG's IsPressed, which a check box has for the same reason a button does. Asked of the behaviour rather than remembered here: a second copy of "is it down" goes stale the first time a press ends somewhere this control does not hear. |
void SetAcceptedMouseButtons(int32 InAcceptedMouseButtons) | callable | Writes the bitmask and pushes it onto the behaviour at once, as the three method setters do. |
void SetCheckedState(EDreamCheckState InCheckedState) | callable | Set any of the three states. Checked/Unchecked go through the behaviour with notify, the path a click takes; Undetermined parks the behaviour at unchecked without notify and lives on the control (see the class comment). |
void SetClickMethod(EDreamUIClickMethod InMethod) | callable | Each of the four setters below writes the field and re-pushes it onto the behaviour. |
void SetIsChecked(bool bInIsChecked) | callable | UMG's convenience spelling of SetIsOn. |
void SetIsOn(bool bInIsOn) | callable | The compatibility spelling of SetCheckedState(Checked/Unchecked). |
void SetPressMethod(EDreamUIPressMethod InMethod) | callable | Set Press Method |
void SetStyle(FDreamToggleStyle InStyle) | callable | This instance's whole look, replaced and pushed. See UDreamButton::SetStyle for the caveat. |
void SetTouchMethod(EDreamUITouchMethod InMethod) | callable | Set Touch Method |
Events
| Event | Signature | Description |
|---|---|---|
OnToggleChanged | void DreamToggleChangedEvent__DelegateSignature(bool bIsOn) | Fired by the toggle underneath, re-broadcast here so a consumer never has to reach into the parts. The compatibility spelling of OnCheckStateChanged: fires whenever the BOOL projection of the state changes (so Unchecked <-> Undetermined moves are silent here). |
OnCheckStateChanged | void DreamCheckStateChangedEvent__DelegateSignature(EDreamCheckState CheckedState) | UMG's spelling of the same moment, carrying the full state. Fires whenever CheckedState changes -- alongside OnToggleChanged when the bool projection moved too. |
OnValueChangedBP | void DreamToggleChangedEvent__DelegateSignature(bool bIsOn) | The <-> convention: two-way bindings synthesize their reverse route against this exact name, so a value control carries it alongside its spoken events. Fires with them. |
OnPressed | void DreamToggleSimpleEvent__DelegateSignature() | The four pointer moments, re-broadcast from the behaviour exactly as the value change is. |
OnReleased | void DreamToggleSimpleEvent__DelegateSignature() | |
OnHovered | void DreamToggleSimpleEvent__DelegateSignature() | |
OnUnhovered | void DreamToggleSimpleEvent__DelegateSignature() |
Compared with UMG
Every Blueprint-facing member of the UMG class, and where it went. adopt: same name, same meaning. map: here under another name or on another type. reject: deliberately absent, with the reason.
| UMG | Member | Status | Here | Note |
|---|---|---|---|---|
UCheckBox | CheckedState | adopt | CheckedState | EDreamCheckState, the same three values. bIsOn is the two-state compatibility spelling and mirrors it. |
UCheckBox | WidgetStyle | map | Style | FDreamToggleStyle. Its CheckedBrush / UncheckedBrush / UndeterminedBrush are UMG's three mark images; StateFaces is the box's per-pointer-state drawing. |
UCheckBox | HorizontalAlignment | reject | This control is a box and its mark, with no content slot at all -- the text beside a check box is the consumer's own layout here. There is nothing for an alignment to align. | |
UCheckBox | ClickMethod | adopt | ClickMethod | EDreamUIClickMethod; pushed onto the selectable underneath. |
UCheckBox | TouchMethod | adopt | TouchMethod | |
UCheckBox | PressMethod | adopt | PressMethod | |
UCheckBox | IsFocusable | map | UDreamWidget::bIsFocusable | Every widget here carries it; a control-level copy would shadow the base member. |
UCheckBox | OnCheckStateChanged | adopt | OnCheckStateChanged | Carries the full state. OnToggleChanged is the bool projection and fires alongside it. Only the mouse buttons in AcceptedMouseButtons press and flip the box -- the left one alone by default, which is SCheckBox's rule; AcceptedMouseButtons is this control's own knob, as on UDreamButton. A double click flips the box twice, as SCheckBox's does: the second press arrives as a double click and the toggle takes it as its press (SCheckBox::OnMouseButtonDoubleClick is OnMouseButtonDown). |
UCheckBox | IsPressed | adopt | IsPressed | Asked of the behaviour's selection state rather than remembered on the control. |
UCheckBox | IsChecked | adopt | IsChecked | |
UCheckBox | GetCheckedState | adopt | GetCheckedState | |
UCheckBox | SetIsChecked | adopt | SetIsChecked | |
UCheckBox | SetCheckedState | adopt | SetCheckedState | Undetermined parks the two-state behaviour at unchecked and lives on the control; a click leaves it by becoming UNCHECKED, as UMG's does (SCheckBox::ToggleCheckedState: Checked or Undetermined becomes Unchecked, Unchecked becomes Checked). |
UCheckBox | SetClickMethod | adopt | SetClickMethod | |
UCheckBox | SetTouchMethod | adopt | SetTouchMethod | |
UCheckBox | SetPressMethod | adopt | SetPressMethod | |
UCheckBox | SetStyle | adopt | SetStyle | Not a UFUNCTION on UCheckBox (its Setter meta names it); added here because a style nothing can replace at runtime is a look only the designer can change. |