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

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<A> EditGuard for StringGuard<A>

Source§

type Data = A

Source§

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

Source§

type Data = A

Source§

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

Source§

type Data = A

Source§

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

Source§

type Data = A