Skip to main content

Module radio

Module radio 

Source
Expand description

<radio> behavior: name-grouped exclusive selection with roving tab index and wrapping arrow-key navigation (Qt QRadioButton in an auto-exclusive group / WAI-ARIA radiogroup).

The markup parser desugars <radio group="g" value="v" label="..."> into a row (tag radio, carrying RadioButton) with a .radio-dot tile child (RadioDot) and a .radio-label label, so every visual is CSS-reachable:

.radio-dot     { width: 18; height: 18; radius: 9; bg: ...; border: ...; }
radio:selected { bg: var(--lumen-accent); }   /* dot fill when on */
radio:focus    { outline: 2 var(--lumen-accent); }

Contract:

  • The GROUP is the set of <radio> elements sharing a group string; the group’s selected value lives in the PropertyStore global of that name (bindable / script-readable like any signal).
  • Exactly one selected per group: sync_radio_selected seeds the first enabled member when the signal is unset.
  • Click (row, dot, or label) and Space select. Arrow keys move selection to the next / previous enabled member, wrapping at the ends and skipping disabled members (web radiogroup behavior; selection follows focus, as in Qt/GTK).
  • Roving tabindex: only the selected (else first enabled) member is in the Tab chain, so Tab enters and leaves the GROUP, not each item (sync_radio_tab_index).

Structs§

RadioButton
One member of a radio group.
RadioDot
Marker on the .radio-dot child tile. Its selected fill is held in StyleOverrides over the dot’s own.
RadioPlugin
Plugin: registers selection dispatch, marker/visual sync, roving tab index, and arrow-key navigation.
RadioStyle
Per-radio fill for the selected dot state, resolved at spawn from radio:selected { bg: ... } (routed through Attributes::selected_bg) with the accent fallback.

Functions§

dispatch_radio_clicks
Click / Space (via the focused-key ClickEvent path) on a radio - or any of its children - writes the member’s value to the group signal AND moves focus to the radio root (Qt: clicking a radio focuses it, so arrow-key navigation picks up right where the pointer left off). Focus is set here as well as on the press because a click raised without one, from the keyboard or a script, still moves it.
radio_group_keys
Arrow keys while a radio holds focus: move selection to the next / previous enabled group member, WRAPPING at the ends (web radiogroup; unlike tabs, which clamp). Selection follows focus - the newly focused member is selected immediately (Qt/GTK). Also moves the Focused + FocusVisible markers and the tracker.
sync_radio_selected
Mirror each group’s signal onto the Selected marker, and enforce exactly-one-selected: a group whose signal is unset (or empty) gets its first enabled member (markup order) selected and the signal seeded.
sync_radio_tab_index
Roving tabindex: exactly one member per group sits in the Tab chain: the selected member, else the first enabled one. Everyone else holds TabIndex(-1), which cycle_focus_on_tab skips, so Tab jumps over the group as a unit in both directions.
sync_radio_visuals
Keep every .radio-dot child in step with its parent’s Selected marker: selected_bg while selected, the dot’s own fill otherwise.