[][src]Trait kas::event::Handler

pub trait Handler: WidgetConfig {
    type Msg;
    pub fn activation_via_press(&self) -> bool { ... }
pub fn handle(
        &mut self,
        _: &mut Manager<'_>,
        event: Event
    ) -> Response<Self::Msg> { ... } }

Event handling for a Widget

This trait is part of the Widget family and is derived by derive(Widget) unless #[handler(handle = noauto)] or #[handler(noauto)] is used.

Interactive widgets should implement their event-handling logic here (although it is also possible to implement this in SendEvent::send, which might be preferable when dealing with child widgets).

The default implementation does nothing, and is derived by derive(Widget) when a #[handler] attribute is present (except with parameter handler=noauto).

Associated Types

type Msg[src]

Type of message returned by this widget

This mechanism allows type-safe handling of user-defined responses to handled actions, for example an enum encoding button presses or a floating-point value from a slider.

The VoidMsg type may be used where messages are never generated. This is distinct from (), which might be applicable when a widget only needs to "wake up" a parent.

Loading content...

Provided methods

pub fn activation_via_press(&self) -> bool[src]

Generic handler: translate presses to activations

This is configuration for Manager::handle_generic, and can be used to translate press (click/touch) events into Event::Activate.

pub fn handle(
    &mut self,
    _: &mut Manager<'_>,
    event: Event
) -> Response<Self::Msg>
[src]

Handle an event and return a user-defined message

Widgets should handle any events applicable to themselves here, and return all other events via Response::Unhandled.

Loading content...

Implementations on Foreign Types

impl<M: 'static> Handler for Box<dyn Widget<Msg = M>>[src]

type Msg = M

impl<M: 'static> Handler for Box<dyn Menu<Msg = M>>[src]

type Msg = M

Loading content...

Implementors

impl Handler for DragHandle[src]

type Msg = Coord

impl Handler for Filler[src]

type Msg = VoidMsg

impl<D: Directional> Handler for ScrollBar<D>[src]

type Msg = u32

impl<D: Directional, M, W: Menu<Msg = M>> Handler for SubMenu<D, W>[src]

type Msg = M

impl<D: Directional, W: Widget> Handler for List<D, W>[src]

type Msg = <W as Handler>::Msg

impl<D: Directional, W: Widget> Handler for Splitter<D, W>[src]

type Msg = <W as Handler>::Msg

impl<D: Directional, W: Menu<Msg = M>, M> Handler for MenuBar<D, W>[src]

type Msg = M

impl<G: EditGuard + 'static> Handler for EditBox<G>[src]

type Msg = G::Msg

impl<M: 'static> Handler for CheckBox<M> where
    M: From<VoidMsg>, 
[src]

type Msg = M

impl<M: 'static> Handler for CheckBoxBare<M>[src]

type Msg = M

impl<M: 'static> Handler for MenuToggle<M> where
    M: From<VoidMsg>, 
[src]

type Msg = M

impl<M: 'static> Handler for RadioBox<M> where
    M: From<VoidMsg>, 
[src]

type Msg = M

impl<M: 'static> Handler for RadioBoxBare<M>[src]

type Msg = M

impl<M: Clone + Debug + 'static> Handler for ComboBox<M>[src]

type Msg = M

impl<M: Clone + Debug + 'static> Handler for MenuEntry<M>[src]

type Msg = M

impl<M: Clone + Debug + 'static> Handler for TextButton<M>[src]

type Msg = M

impl<M: Debug + 'static> Handler for Separator<M>[src]

type Msg = M

impl<T: FormattableText + 'static> Handler for Label<T>[src]

type Msg = VoidMsg

impl<T: FormattableText + 'static> Handler for MessageBox<T>[src]

type Msg = VoidMsg

impl<T: SliderType, D: Directional> Handler for Slider<T, D>[src]

type Msg = T

impl<W: Widget + 'static> Handler for Window<W> where
    W: Widget<Msg = VoidMsg>, 
[src]

type Msg = VoidMsg

impl<W: Widget> Handler for Frame<W>[src]

type Msg = <W as Handler>::Msg

impl<W: Widget> Handler for MenuFrame<W>[src]

type Msg = <W as Handler>::Msg

impl<W: Widget> Handler for ScrollRegion<W>[src]

type Msg = <W as Handler>::Msg

impl<W: Widget> Handler for Stack<W>[src]

type Msg = <W as Handler>::Msg

Loading content...