Skip to main content

euv_core/event/handler/
struct.rs

1use crate::*;
2
3/// Inner storage for a native event callback closure.
4///
5/// Boxes a `dyn FnMut(Event)` so it can be stored behind `Rc<RefCell<>>`.
6#[derive(CustomDebug, Data, New)]
7pub(crate) struct NativeEventCallbackInner {
8    /// The boxed callback closure.
9    #[debug(skip)]
10    #[get(pub(crate))]
11    #[get_mut(pub(crate))]
12    #[set(pub(crate))]
13    pub(crate) callback: Box<dyn FnMut(Event)>,
14}
15
16/// A wrapper around an event callback.
17///
18/// Stores the event name and a shared reference to the heap-allocated callback closure.
19#[derive(Clone, CustomDebug, Data, New)]
20pub struct NativeEventHandler {
21    /// The name of the event (e.g., "click", "input").
22    #[get(pub(crate), type(copy))]
23    #[get_mut(pub(crate))]
24    #[set(pub(crate))]
25    pub(crate) event_name: &'static str,
26    /// Shared reference to the heap-allocated callback closure inner state.
27    #[debug(skip)]
28    #[get(pub(crate))]
29    #[get_mut(pub(crate))]
30    #[set(pub(crate))]
31    pub(crate) callback: Rc<RefCell<NativeEventCallbackInner>>,
32}