Skip to main content

Form

Trait Form 

Source
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§

Source

type Field: Copy + Eq + Debug

The modal’s name for a field.

Required Methods§

Source

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.

Source

fn focused(&self) -> Self::Field

Source

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§

Source

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.

Source

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.

Source

fn focused_kind(&self) -> Option<FieldKind>

The focused field’s kind; None when focus is on a field not shown.

Source

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.

Source

fn dismiss_picker(&mut self)

Close the open picker, choosing nothing.

Source

fn pick(&mut self, _toggle: bool)

Take the picker’s item and close it, or with toggle, flip it and stay open.

Source

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.

Source

fn move_focus(&mut self, delta: isize)

Move focus delta fields along, wrapping. A focus the form no longer shows counts from the top.

Source

fn focus_next(&mut self)

Source

fn focus_prev(&mut self)

Source

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".

Implementors§