Trait kas_widgets::edit::EditGuard
source · pub trait EditGuard: Sized {
type Data;
// Provided methods
fn configure(edit: &mut EditField<Self>, cx: &mut ConfigCx<'_>) { ... }
fn update(
edit: &mut EditField<Self>,
cx: &mut ConfigCx<'_>,
data: &Self::Data
) { ... }
fn activate(
edit: &mut EditField<Self>,
cx: &mut EventCx<'_>,
data: &Self::Data
) -> IsUsed { ... }
fn focus_gained(
edit: &mut EditField<Self>,
cx: &mut EventCx<'_>,
data: &Self::Data
) { ... }
fn focus_lost(
edit: &mut EditField<Self>,
cx: &mut EventCx<'_>,
data: &Self::Data
) { ... }
fn edit(edit: &mut EditField<Self>, cx: &mut EventCx<'_>, data: &Self::Data) { ... }
}
Expand description
Event-handling guard for EditField
, EditBox
This is the most generic interface; see also constructors of EditField
,
EditBox
for common use-cases.
All methods on this trait are passed a reference to the EditField
as
parameter. The guard itself is a public field: edit.guard
.
All methods have a default implementation which does nothing.
Required Associated Types§
Provided Methods§
sourcefn configure(edit: &mut EditField<Self>, cx: &mut ConfigCx<'_>)
fn configure(edit: &mut EditField<Self>, cx: &mut ConfigCx<'_>)
Configure guard
This function is called when the attached widget is configured.
sourcefn update(edit: &mut EditField<Self>, cx: &mut ConfigCx<'_>, data: &Self::Data)
fn update(edit: &mut EditField<Self>, cx: &mut ConfigCx<'_>, data: &Self::Data)
Update guard
This function is called when input data is updated.
Note that this method may be called during editing as a result of a
message sent by Self::edit
or another cause. It is recommended to
ignore updates for editable widgets with key focus
(EditField::has_edit_focus
) to avoid overwriting user input;
Self::focus_lost
may update the content instead.
For read-only fields this is not recommended (but has_edit_focus
will
not be true anyway).
sourcefn activate(
edit: &mut EditField<Self>,
cx: &mut EventCx<'_>,
data: &Self::Data
) -> IsUsed
fn activate( edit: &mut EditField<Self>, cx: &mut EventCx<'_>, data: &Self::Data ) -> IsUsed
Activation guard
This function is called when the widget is “activated”, for example by
the Enter/Return key for single-line edit boxes. Its result is returned
from handle_event
.
The default implementation:
- If the field is editable, calls
Self::focus_lost
and returns returnsUsed
. - If the field is not editable, returns
Unused
.
sourcefn focus_gained(
edit: &mut EditField<Self>,
cx: &mut EventCx<'_>,
data: &Self::Data
)
fn focus_gained( edit: &mut EditField<Self>, cx: &mut EventCx<'_>, data: &Self::Data )
Focus-gained guard
This function is called when the widget gains keyboard input focus.
sourcefn focus_lost(
edit: &mut EditField<Self>,
cx: &mut EventCx<'_>,
data: &Self::Data
)
fn focus_lost( edit: &mut EditField<Self>, cx: &mut EventCx<'_>, data: &Self::Data )
Focus-lost guard
This function is called when the widget loses keyboard input focus.