pub enum Role {
Show 13 variants
Button,
CheckBox,
Radio,
Switch,
Tab,
MenuItem,
Slider,
SpinButton,
TextInput,
MultilineTextInput,
ComboBox,
Disclosure,
Label,
}Expand description
What a focusable is, for the reader that has to say it out loud — a separate question from FocusKind,
which asks what the widget does with a key.
Defined in platform-core because it is the vocabulary the UI and the platform share, the same way
Key is. Re-exported here because this is where it is authored: a widget declares its role at the
moment it declares itself focusable, and the two are one call.
What a control is, for the reader that has to say it out loud.
A separate question from what a widget does with a key: both a checkbox and a button take keys as commands, and only one of them is a thing you can be told the state of. The list is short on purpose — these are the roles a real catalogue has, not a transcription of any platform’s vocabulary — and each backend maps them outwards to its own.
Variants§
Button
The default, and right for anything whose whole meaning is “activating this does something”.
CheckBox
Carries a checked state that is part of what it is, not of what it looks like.
Radio
One of a set where choosing it unchooses the others.
Switch
A checkbox that reads as a switch: on or off rather than ticked or not.
Tab
Picks one of several panels.
MenuItem
A row of a menu or a bound list.
Slider
A continuous value dragged along a track.
SpinButton
A discrete value with a step, typed or nudged.
TextInput
A single-line field.
MultilineTextInput
A multi-line editor.
ComboBox
Opens a list of choices and names the current one.
Disclosure
A region that reads as one thing and can be collapsed.
Label
Not a control at all: text the interface is showing. Never focusable — it is here because a reader given only the buttons cannot say what the buttons are for.