zng::widget::node

Function event_state

source
pub fn event_state<A, S>(
    child: impl UiNode,
    state: impl IntoVar<S>,
    default: S,
    event: Event<A>,
    on_event: impl FnMut(&A) -> Option<S> + Send + 'static,
) -> impl UiNode
where A: EventArgs, S: VarValue,
Expand description

Helper for declaring state properties that depend on a single event.

When the event is received on_event is called, if it provides a new state the state variable is set.