pub trait WidgetHandler<A: Clone + 'static>: Any + Send {
// Required method
fn event(&mut self, args: &A) -> bool;
// Provided methods
fn update(&mut self) -> bool { ... }
fn boxed(self) -> Box<dyn WidgetHandler<A>>
where Self: Sized { ... }
fn cfg_boxed(self) -> Box<dyn WidgetHandler<A>>
where Self: Sized { ... }
}
Expand description
Represents a handler in a widget context.
There are different flavors of handlers, you can use macros to declare then.
See hn!
, hn_once!
or async_hn!
, async_hn_once!
to start.
Required Methods§
Provided Methods§
sourcefn update(&mut self) -> bool
fn update(&mut self) -> bool
Called every widget update.
Returns false
when all pending async tasks are completed. Note that event properties
will call this method every update even if it is returning false
.
sourcefn boxed(self) -> Box<dyn WidgetHandler<A>>where
Self: Sized,
fn boxed(self) -> Box<dyn WidgetHandler<A>>where
Self: Sized,
Box the handler.
The type Box<dyn WidgetHandler<A>>
implements WidgetHandler<A>
and just returns itself
in this method, avoiding double boxing.
sourcefn cfg_boxed(self) -> Box<dyn WidgetHandler<A>>where
Self: Sized,
fn cfg_boxed(self) -> Box<dyn WidgetHandler<A>>where
Self: Sized,
Boxes the handler if the feature = "dyn_closure"
is active, otherwise retains the same handler type.