Trait kas::event::Handler [−][src]
pub trait Handler: WidgetConfig {
type Msg;
fn activation_via_press(&self) -> bool { ... }
fn focus_on_key_nav(&self) -> bool { ... }
fn handle(
&mut self,
mgr: &mut Manager<'_>,
event: Event
) -> Response<Self::Msg> { ... }
}
Expand description
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 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.
Provided methods
fn activation_via_press(&self) -> bool
fn activation_via_press(&self) -> bool
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
.
Generic handler: focus rect on key navigation
If this widget receives Event::NavFocus
(true)
then return
Response::Focus
with the widget’s rect. By default this is true if
and only if WidgetConfig::key_nav
is true.