zng::handler

Trait WidgetHandler

source
pub trait WidgetHandler<A>: Any + Send
where A: Clone + 'static,
{ // 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§

source

fn event(&mut self, args: &A) -> bool

Called every time the handler’s event happens in the widget context.

Returns true when the event handler is async and it has not finished handling the event.

Provided Methods§

source

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.

source

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.

source

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.

Trait Implementations§

source§

impl<A> WidgetHandler<A> for Box<dyn WidgetHandler<A>>
where A: Clone + 'static,

source§

fn event(&mut self, args: &A) -> bool

Called every time the handler’s event happens in the widget context. Read more
source§

fn update(&mut self) -> bool

Called every widget update. Read more
source§

fn boxed(self) -> Box<dyn WidgetHandler<A>>
where Box<dyn WidgetHandler<A>>: Sized,

Box the handler. Read more
source§

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.

Implementations on Foreign Types§

source§

impl<A> WidgetHandler<A> for Box<dyn WidgetHandler<A>>
where A: Clone + 'static,

source§

fn event(&mut self, args: &A) -> bool

source§

fn update(&mut self) -> bool

source§

fn boxed(self) -> Box<dyn WidgetHandler<A>>
where Box<dyn WidgetHandler<A>>: Sized,

Implementors§

source§

impl<A> WidgetHandler<A> for ArcWidgetHandler<A>
where A: Clone + 'static,

source§

impl<A, H, F> WidgetHandler<A> for FilterWidgetHandler<A, H, F>
where A: Clone + 'static, H: WidgetHandler<A>, F: FnMut(&A) -> bool + Send + 'static,