Skip to main content

Module checkbox

Module checkbox 

Source
Expand description

<checkbox> behavior: box + label control on top of the shared Toggleable machinery, with a tri-state indeterminate mode.

The markup parser desugars <checkbox label="..."> into a row (tag checkbox, carrying Toggleable + CheckboxStyle) with two real child elements - a .checkbox-box tile (carrying CheckboxBox) and a .checkbox-label label - so every visual is CSS-reachable through the skins:

.checkbox-box     { width: 18; height: 18; bg: ...; border: ...; }
checkbox:checked  { bg: var(--lumen-accent); }  /* box fill when on */
checkbox:focus    { outline: 2 var(--lumen-accent); }

Behavior reuse:

  • Click anywhere on the row (box, label, gap) toggles - crate::controls::flip_toggle_on_click resolves child hits to the ancestor Toggleable, exactly like <toggle>.
  • Space on the focused checkbox toggles - lumen_input::activate_focused_on_enter’s press-and-release FSM emits the same ClickEvent.
  • bind-checked / on_toggle(id, checked) come with Toggleable.

Tri-state: indeterminate="true" inserts the Indeterminate marker. The box renders a dash while it’s present; the first user toggle (click / Space - anything that fires crate::controls::ToggleChanged) clears it, mirroring the web’s indeterminate IDL attribute and Qt’s PartiallyChecked. Script bind-checked writes do not clear it.

Structs§

CheckboxBox
Marker on the .checkbox-box child tile. Its checked fill is held in StyleOverrides over the box’s own.
CheckboxPlugin
Plugin: registers the visual sync + indeterminate-clear systems. The toggle behavior itself ships with crate::ControlsPlugin.
CheckboxStyle
Per-checkbox fill for the checked / indeterminate box state, resolved at spawn from checkbox:checked { bg: ... } (routed through Attributes::checked_bg) with the accent fallback.
Indeterminate
Tri-state marker on the checkbox ROOT: renders a dash regardless of checked until the first user toggle removes it.

Functions§

clear_indeterminate_on_user_toggle
First user toggle clears Indeterminate (web/Qt tri-state contract). Listens to ToggleChanged - fired only by the user input path, not by bind-checked signal pulls.
sync_checkbox_visuals
Keep every .checkbox-box child in step with its parent state: