Skip to main content

EditGuard

Trait EditGuard 

Source
pub trait EditGuard: Sized {
    type Data;

    // Provided methods
    fn configure(&mut self, edit: &mut Editor, cx: &mut ConfigCx<'_>) { ... }
    fn update(
        &mut self,
        edit: &mut Editor,
        cx: &mut ConfigCx<'_>,
        data: &Self::Data,
    ) { ... }
    fn activate(
        &mut self,
        edit: &mut Editor,
        cx: &mut EventCx<'_>,
        data: &Self::Data,
    ) -> IsUsed { ... }
    fn focus_gained(
        &mut self,
        edit: &mut Editor,
        cx: &mut EventCx<'_>,
        data: &Self::Data,
    ) { ... }
    fn focus_lost(
        &mut self,
        edit: &mut Editor,
        cx: &mut EventCx<'_>,
        data: &Self::Data,
    ) { ... }
    fn edit(
        &mut self,
        edit: &mut Editor,
        cx: &mut EventCx<'_>,
        data: &Self::Data,
    ) { ... }
}
Expand description

Event-handling guard for an Editor

This is the most generic interface; see also constructors of EditField, EditBox for common use-cases.

All methods have a default implementation which does nothing.

Required Associated Types§

Source

type Data

Data type

Provided Methods§

Source

fn configure(&mut self, edit: &mut Editor, cx: &mut ConfigCx<'_>)

Configure guard

This function is called when the attached widget is configured.

Source

fn update( &mut self, edit: &mut Editor, cx: &mut ConfigCx<'_>, data: &Self::Data, )

Update guard

This function is called when input data is updated and the editor does not have input focus.

This method may also be called on loss of input focus (see Self::focus_lost).

Source

fn activate( &mut self, edit: &mut Editor, 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( &mut self, edit: &mut Editor, cx: &mut EventCx<'_>, data: &Self::Data, )

Focus-gained guard

This function is called when the widget gains keyboard or IME focus.

Source

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

Focus-lost guard

This function is called after the widget has lost both keyboard and IME focus.

The default implementation calls Self::update since updates are inhibited while the editor has input focus.

Source

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

Edit guard

This function is called after the text is updated (including by keyboard input, an undo action or by a message like kas::messages::SetValueText). The exceptions are setter methods like clear and set_string.

The guard may call Editor::set_error here. The error state is cleared immediately before calling this method.

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