Trait kas_widgets::EditGuard [−][src]
pub trait EditGuard: Debug + Sized + 'static {
type Msg;
fn activate(
edit: &mut EditField<Self>,
mgr: &mut Manager<'_>
) -> Option<Self::Msg> { ... }
fn focus_gained(edit: &mut EditField<Self>, mgr: &mut Manager<'_>) { ... }
fn focus_lost(
edit: &mut EditField<Self>,
mgr: &mut Manager<'_>
) -> Option<Self::Msg> { ... }
fn edit(
edit: &mut EditField<Self>,
mgr: &mut Manager<'_>
) -> Option<Self::Msg> { ... }
fn update(edit: &mut EditField<Self>) { ... }
}
Expand description
A guard around an EditField
When an EditField
receives input, it updates its contents as expected,
then invokes a method of EditGuard
. This method may update the
EditField
and may return a message to be returned by the EditField
’s
event handler.
All methods on this trait are passed a reference to the EditField
as
parameter. The EditGuard
’s state may be accessed via the
EditField::guard
public field.
All methods have a default implementation which does nothing.
This trait is implemented for ()
(does nothing; Msg = VoidMsg).
Associated Types
The event::Handler::Msg
type
Provided methods
Activation guard
This function is called when the widget is “activated”, for example by
the Enter/Return key for single-line edit boxes. Its return value is
converted to Response::None
or Response::Msg
.
Note that activation events cannot edit the contents.
fn focus_gained(edit: &mut EditField<Self>, mgr: &mut Manager<'_>)
fn focus_gained(edit: &mut EditField<Self>, mgr: &mut Manager<'_>)
Focus-gained guard
This function is called when the widget gains keyboard input focus.
Focus-lost guard
This function is called when the widget loses keyboard input focus. Its
return value is converted to Response::None
or Response::Msg
.
Edit guard
This function is called when contents are updated by the user (but not
on programmatic updates — see also EditGuard::update
). Its return
value is converted to Response::Update
or Response::Msg
.
The default implementation calls EditGuard::update
.
Update guard
This function is called on any programmatic update to the contents
(and potentially also by EditGuard::edit
).