"nvmnd" (event FnMut)

This commit is contained in:
iris committed 2025-12-10 13:56:38 -05:00
1 parent 76f75192d5
commit 2537284372
4 files changed
+17 -18

No files matched your search

+4 -5
View File
@@ -3,7 +3,6 @@ use crate::{
layout::{UiModule, UiRegion, Vec2},
util::HashMap,
};
use std::cell::RefCell;
use std::{
ops::{BitOr, Deref, DerefMut},
rc::Rc,
@@ -98,7 +97,7 @@ pub enum ActivationState {
/// but I'm not sure how or if worth it
pub struct Sensor<Ctx, Data> {
pub senses: CursorSenses,
pub f: Rc<RefCell<dyn EventFn<Ctx, Data>>>,
pub f: Rc<dyn EventFn<Ctx, Data>>,
}
pub type SensorMap<Ctx, Data> = HashMap<WidgetId, SensorGroup<Ctx, Data>>;
@@ -208,7 +207,7 @@ impl<Ctx: 'static> CursorModule<Ctx> {
scroll_delta: cursor.scroll_delta,
sense,
};
(sensor.f.borrow_mut())(EventCtx {
(sensor.f)(EventCtx {
ui,
state: ctx,
data,
@@ -309,7 +308,7 @@ impl<E: Event<Data = <CursorSenses as Event>::Data> + Into<CursorSenses>, Ctx: '
// TODO: does not add to active if currently active
self.map.entry(id).or_default().sensors.push(Sensor {
senses: senses.into(),
f: Rc::new(RefCell::new(f)),
f: Rc::new(f),
});
}
@@ -333,7 +332,7 @@ impl<E: Event<Data = <CursorSenses as Event>::Data> + Into<CursorSenses>, Ctx: '
.collect();
Some(move |ctx: EventCtx<Ctx, CursorData>| {
for f in fs {
f.borrow_mut()(EventCtx {
f(EventCtx {
state: ctx.state,
ui: ctx.ui,
data: ctx.data.clone(),