Trait kas::widgets::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§

source

type Data

Data type

Provided Methods§

source

fn configure(edit: &mut EditField<Self>, cx: &mut ConfigCx<'_>)

Configure guard

This function is called when the attached widget is configured.

source

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

source

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:

source

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.

source

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.

source

fn edit(edit: &mut EditField<Self>, cx: &mut EventCx<'_>, data: &Self::Data)

Edit guard

This function is called when contents are updated by the user.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl EditGuard for AflGuard

§

type Data = ()

source§

impl EditGuard for KeystrokeGuard

§

type Data = ()

source§

impl<A> EditGuard for DefaultGuard<A>
where A: 'static,

§

type Data = A

source§

impl<A> EditGuard for StringGuard<A>

§

type Data = A

source§

impl<A, T> EditGuard for InstantParseGuard<A, T>
where T: Debug + Display + FromStr,

§

type Data = A

source§

impl<A, T> EditGuard for ParseGuard<A, T>
where T: Debug + Display + FromStr,

§

type Data = A