zng_wgt::node

Function on_pre_event

source
pub fn on_pre_event<C, A, F, H>(
    child: C,
    event: Event<A>,
    filter: F,
    handler: H,
) -> impl UiNode
where C: UiNode, A: EventArgs, F: FnMut(&A) -> bool + Send + 'static, H: WidgetHandler<A>,
Expand description

Helper for declaring preview event properties.

This function is used by the event_property! macro.

§Filter

The filter predicate is called if propagation was not stopped. It must return true if the event arguments are relevant in the context of the widget. If it returns true the handler closure is called. Note that events that represent an interaction with the widget are send for both ENABLED and DISABLED targets, event properties should probably distinguish if they fire on normal interactions vs on disabled interactions.

§Route

The event handler is called before the on_event equivalent at the same context level. If the event filter allows more then one widget and one widget contains the other, the handler is called on the inner widget first.

§Async

Async event handlers are called like normal, but code after the first .await only runs in subsequent event updates. This means that propagation must be stopped before the first .await, otherwise you are only signaling other async tasks handling the same event, if they are monitoring the propagation handle.

§Commands

You can use on_pre_command to declare command event properties.