pub trait Form {
type Field: Copy + Eq + Debug;
Show 14 methods
// Required methods
fn fields(&self) -> Vec<(Self::Field, FieldKind)>;
fn focused(&self) -> Self::Field;
fn set_focused(&mut self, field: Self::Field);
// Provided methods
fn text_edge(&self, _field: Self::Field) -> (bool, bool) { ... }
fn list_row(&self, _field: Self::Field) -> bool { ... }
fn focused_kind(&self) -> Option<FieldKind> { ... }
fn shown_picker(&mut self) -> Option<(&mut PickerState, bool)> { ... }
fn dismiss_picker(&mut self) { ... }
fn pick(&mut self, _toggle: bool) { ... }
fn focus(&mut self, field: Self::Field) -> bool { ... }
fn move_focus(&mut self, delta: isize) { ... }
fn focus_next(&mut self) { ... }
fn focus_prev(&mut self) { ... }
fn settle_focus(&mut self) { ... }
}Expand description
A form: its fields in order and the one with focus. The modal owns both; the default methods move focus the same way for every form.
Required Associated Types§
Required Methods§
Sourcefn fields(&self) -> Vec<(Self::Field, FieldKind)>
fn fields(&self) -> Vec<(Self::Field, FieldKind)>
The fields on screen, top to bottom, each with its kind. A field the current state hides or disables is left out, so focus never lands on it.
fn focused(&self) -> Self::Field
Sourcefn set_focused(&mut self, field: Self::Field)
fn set_focused(&mut self, field: Self::Field)
Put focus on field. Called only with a field of Form::fields; a modal
that shows a text cursor in the focused field syncs it here.
Provided Methods§
Sourcefn text_edge(&self, _field: Self::Field) -> (bool, bool)
fn text_edge(&self, _field: Self::Field) -> (bool, bool)
For a multiline field: whether its cursor is on the first line, and on the last, where ↑ and ↓ leave it.
Sourcefn list_row(&self, _field: Self::Field) -> bool
fn list_row(&self, _field: Self::Field) -> bool
Whether field is a row of a list (a sort, a filter, a column) rather than a
setting. A click on a list row only focuses it, so it can be picked to move or
remove without changing it; a click on it once focused acts. A setting (a
checkbox, a choice, a button) acts on the first click.
Sourcefn focused_kind(&self) -> Option<FieldKind>
fn focused_kind(&self) -> Option<FieldKind>
The focused field’s kind; None when focus is on a field not shown.
Sourcefn shown_picker(&mut self) -> Option<(&mut PickerState, bool)>
fn shown_picker(&mut self) -> Option<(&mut PickerState, bool)>
The picker open over a field, and whether it takes several values; None
for a form with no picker open.
Sourcefn dismiss_picker(&mut self)
fn dismiss_picker(&mut self)
Close the open picker, choosing nothing.
Sourcefn pick(&mut self, _toggle: bool)
fn pick(&mut self, _toggle: bool)
Take the picker’s item and close it, or with toggle, flip it and stay open.
Sourcefn focus(&mut self, field: Self::Field) -> bool
fn focus(&mut self, field: Self::Field) -> bool
Focus field if the form shows it: a click on a row, or a modal moving
focus itself. Returns whether it did.
Sourcefn move_focus(&mut self, delta: isize)
fn move_focus(&mut self, delta: isize)
Move focus delta fields along, wrapping. A focus the form no longer shows
counts from the top.
fn focus_next(&mut self)
fn focus_prev(&mut self)
Sourcefn settle_focus(&mut self)
fn settle_focus(&mut self)
After a change that hides fields: when the focused one went, focus the first field instead, so it never points at nothing.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".