pub struct Status {Show 18 fields
pub interaction: Interaction,
pub focused: bool,
pub cursor: Option<usize>,
pub selection: Option<(usize, usize)>,
pub composing: Option<(usize, usize)>,
pub handles: bool,
pub caret_hidden: bool,
pub drag_over: bool,
pub hover_progress: f32,
pub focus_progress: f32,
pub press_progress: f32,
pub opacity: f32,
pub value: f32,
pub time: f32,
pub anim_color: Option<Color>,
pub anim_radius: Option<BorderRadius>,
pub scroll_y: f32,
pub hover_cursor: Option<Point>,
}Expand description
A widget’s complete status for one frame: pointer interaction, focus, caret and selection (for fields), animation progress and opacity.
Fields§
§interaction: InteractionWhether the pointer is over the widget or pressing it.
focused: boolWhether the widget holds the keyboard focus.
cursor: Option<usize>The caret’s (character) index, if this widget is a focused field.
selection: Option<(usize, usize)>The selected (start, end) range, in character indices.
composing: Option<(usize, usize)>The (start, end) range being composed by the IME (provisional,
underlined text); None outside composition. In character indices.
handles: boolDoes the selection carry handles? A selection made with a finger does — a long press on a word — and one made with a mouse or the keyboard does not. Set by the shell, and only for the focused field.
Is the caret in the hidden half of its blink? Set by the shell, and only for the focused field; a field paints no caret while it is.
drag_over: boolIs a drag currently over this widget, and would it be accepted? Only
ever true for a crate::DragTarget; it is what lets one paint the “drop it
here” state itself rather than have the shell paint it from outside.
hover_progress: f32The hover transition’s progress (0.0..=1.0).
focus_progress: f32The focus transition’s progress (0.0..=1.0).
press_progress: f32The press transition’s progress (0.0..=1.0): the animated form of
Interaction::Pressed, as hover_progress is the animated form of
Interaction::Hovered.
A press used to be a flag and nothing else, so every state layer and every held
radius in the crate reached full the instant a finger landed and vanished the
instant it left. The reference fades its press highlight over 200 ms against the
50 ms it gives hover and focus (ink_well.dart:995) — the press is the slower
of the two, which is the opposite of what a flag does.
interaction stays for the decisions that really are discrete — is this the
widget being held? — and this is what the paint reads.
opacity: f32The opacity to apply (a fade-in); 1.0 = opaque.
value: f32The widget’s own animated value (a switch’s 0 → 1, for instance), driven
by Widget::anim_target.
time: f32The time elapsed (in seconds) since start-up — for continuous,
time-driven animations (a CircularProgressIndicator, for instance).
anim_color: Option<Color>The interpolated color of an animated background
(Container::animated_color) while in transition; None = no animated
color, and the widget uses its own.
anim_radius: Option<BorderRadius>The interpolated corner radius (Container::animated_radius) while in
transition; None = a fixed radius, and the widget uses its own.
scroll_y: f32This widget’s retained vertical scroll (in px), for widgets that scroll
their own content (a multi-line field); 0 otherwise.
hover_cursor: Option<Point>The pointer’s absolute position when it hovers an interactive sub-region of
this widget (milestone 208); None otherwise. The widget brings it back to local
coordinates through its bounds to highlight the targeted zone (a suffix icon…).
Set by the shell from cursor_icon.
Implementations§
Source§impl Status
impl Status
Sourcepub fn states(&self) -> WidgetStates
pub fn states(&self) -> WidgetStates
The states this widget is in, as a WidgetStateProperty resolves against
(widget_state.dart:168).
Three of the eight, because three are all a status honestly knows: hovered,
focused and pressed. Selected, Disabled, Error, Dragged and
ScrolledUnder are the widget’s own to add with
WidgetStates::set — nothing outside a checkbox knows whether it is ticked, and
a status that guessed would be wrong for every widget that never selects anything.
It reads the flags, not the fades: a property is a step between values, and where the change should be gradual the widget animates between two resolved values rather than resolving a fraction. See the module note.