"nvmnd" (event FnMut)
This commit is contained in:
1 parent
76f75192d5
commit
2537284372
4 files changed
+17
-18
No files matched your search
+1
-1
@@ -91,7 +91,7 @@ impl<State: DefaultAppState> AppState for DefaultState<State> {
|
||||
|
||||
let input_changed = ui_state.input.event(&event);
|
||||
let cursor_state = ui_state.cursor_state().clone();
|
||||
let old = ui_state.focus.clone();
|
||||
let old = ui_state.focus;
|
||||
if cursor_state.buttons.left.is_start() {
|
||||
ui_state.focus = None;
|
||||
}
|
||||
|
||||
+4
-5
@@ -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(),
|
||||
|
||||
Reference in new issue
Block a user