macro_rules! event_handler {
($vis:vis $name:ident : $t:ty = $cell:expr, $fn:expr) => { ... };
}Expand description
Declare a static crate::lvgl::EventHandler<T> for LVGL event callbacks.
Bundles a &'static InitCell<T> of shared state with a safe
fn(&T, EventCtx) callback. Pass the resulting static to
EventTarget::on_with or
EventTarget::on_clicked_with.
§Example
ⓘ
struct NavState { page: i32 }
ove::shared!(NAV: ove::lvgl::LvCell<NavState>);
fn on_next(state: &ove::lvgl::LvCell<NavState>, _e: ove::lvgl::EventCtx<'_>) {
state.update(|s| NavState { page: s.page + 1 });
}
ove::event_handler!(NAV_NEXT: LvCell<NavState> = &NAV, on_next);
// ...later: button.on_clicked_with(&NAV_NEXT);