Expand description
A field’s state, one model for every input (text fields, numbers, paths, sliders): whether it is modified, required, invalid, disabled (and why), read-only or pending.
Experimental: may change in any release
(docs/stability.md).
The state is data: a widget draws it (an edge, a marker and an icon
per state, never colour alone), gives it to assistive technologies and
reports it to agents. Which states a field has comes from the
application (validation, what the field depends on); FieldState
only says how they combine.
use egui_pop_model::field::{Baseline, FieldState, Mark};
let state = FieldState::new()
.required()
.modified(Baseline::Default)
.invalid("Give a name");
assert!(state.is_editable());
assert_eq!(state.edge(), Some(Mark::Invalid));
assert_eq!(state.marks(), vec![Mark::Invalid, Mark::Modified, Mark::Required]);
let off = FieldState::new().disabled("Needs an open image");
assert!(!off.is_focusable());
assert_eq!(off.disabled_reason(), Some("Needs an open image"));Structs§
- Field
State - A field’s state. The default is a plain field: editable, optional, valid, unchanged.
- Modified
- How a field is modified.