idk work (r + h)

This commit is contained in:
2025-12-11 23:05:27 -05:00
parent a70d09e162
commit a708813ce7
11 changed files with 152 additions and 102 deletions

View File

@@ -1,5 +1,31 @@
use crate::prelude::*;
pub mod eventable {
use super::*;
widget_trait! {
pub trait Eventable;
fn on<E: Event, Ctx: 'static>(
self,
event: E,
f: impl WidgetEventFn<Ctx, E::Data, WL::Widget>,
) -> impl WidgetIdFn<WL::Widget> {
move |ui| {
let id = self.handles(ui);
ui.register_event(&id.r, event, move |ctx| {
f(EventIdCtx {
widget: id.r,
state: ctx.state,
data: ctx.data,
ui: ctx.ui,
});
});
id.h
}
}
}
}
// TODO: naming in here is a bit weird like eventable
#[macro_export]
macro_rules! event_ctx {
@@ -31,29 +57,3 @@ macro_rules! event_ctx {
};
}
pub use event_ctx;
pub mod eventable {
use super::*;
widget_trait! {
pub trait Eventable;
fn on<E: Event, Ctx: 'static>(
self,
event: E,
f: impl WidgetEventFn<Ctx, E::Data, WL::Widget>,
) -> impl WidgetIdFn<WL::Widget> {
move |ui| {
let id = self.handles(ui);
ui.register_event(&id.1, event, move |ctx| {
f(EventIdCtx {
id: id.1,
state: ctx.state,
data: ctx.data,
ui: ctx.ui,
});
});
id.0
}
}
}
}