Skip to main content

Module toggle_button

Module toggle_button 

Source
Expand description

Buttons that stay in: one on its own, and a run of them.

§Why this is not a Switch

A switch is a setting. Flipping it applies something to the world — the window goes dark, the daemon starts — and it is drawn as a setting, with a label beside a track, so a reader can tell at a glance which of two states the machine is in without acting on anything.

A toggle is a button. Pressing it does not change a setting; it changes what the next thing you do means, and it looks like a button because you act on it. Bold in a formatting bar is a toggle: it stays in, but nothing became bold when it went in. The published roles say the same thing — Switch publishes Role::Switch, a toggle publishes Role::Button carrying a checked state — so a reader is never told a button is a setting.

Both exist because a host that has only one of them has to lie with the other, and the lie is not cosmetic: a switch nobody applied is a switch reporting a state the machine is not in.

§Why this is not a SegmentedControl

A segmented control is a radio group in a strip: exactly one segment holds, always, and there is no keystroke or click that empties it. That is the right control for a required choice among a few, and ToggleGroup does not reimplement it.

What a segmented control cannot say is none and cannot say several, and those are the two cases here, which is why the modes are named ToggleSelection::AtMostOne and ToggleSelection::Any rather than single and multiple. If the answer is required, reach for a segmented control.

Structs§

Toggle
A button that stays in.
ToggleGroup
A run of toggles where none, one, or several may be in.
ToggleItem
One toggle in a group, identified by business identity.

Enums§

ToggleSelection
How many of a group’s toggles may be in at once.