diff --git a/lib/rust/ensogl/core/src/control/io/mouse.rs b/lib/rust/ensogl/core/src/control/io/mouse.rs index 98c47d4d647..8b2db9037df 100644 --- a/lib/rust/ensogl/core/src/control/io/mouse.rs +++ b/lib/rust/ensogl/core/src/control/io/mouse.rs @@ -151,32 +151,3 @@ define_bindings! { MouseEvent::mouseleave => on_leave (OnLeave), WheelEvent::wheel => on_wheel (OnWheel), } - -/// A handles of callbacks emitting events on bound FRP graph. See `callback::Handle`. -#[derive(Debug)] -pub struct MouseFrpCallbackHandles { - on_move: callback::Handle, - on_down: callback::Handle, - on_up: callback::Handle, - on_wheel: callback::Handle, -} - -// FIXME: This is obsolete. Use mouse bindings from scene instead. -/// Bind FRP graph to MouseManager. -pub fn bind_frp_to_mouse(frp: &Mouse, mouse_manager: &MouseManager) -> MouseFrpCallbackHandles { - let dom_shape = mouse_manager.dom.clone_ref().shape(); - let on_move = enclose!((frp.position => frp) move |e:&OnMove| { - let position = Vector2(e.client_x() as f32,e.client_y() as f32); - let position = position - Vector2(dom_shape.width,dom_shape.height) / 2.0; - frp.emit(position); - }); - let on_down = enclose!((frp.down => frp) move |_:&OnDown | frp.emit(Button0)); - let on_up = enclose!((frp.up => frp) move |_:&OnUp | frp.emit(Button0)); - let on_wheel = enclose!((frp.wheel => frp) move |_:&OnWheel| frp.emit(())); - MouseFrpCallbackHandles { - on_move: mouse_manager.on_move.add(on_move), - on_down: mouse_manager.on_down.add(on_down), - on_up: mouse_manager.on_up.add(on_up), - on_wheel: mouse_manager.on_wheel.add(on_wheel), - } -} diff --git a/lib/rust/ensogl/core/src/display/scene.rs b/lib/rust/ensogl/core/src/display/scene.rs index 98ae9a136af..7caab97bf6e 100644 --- a/lib/rust/ensogl/core/src/display/scene.rs +++ b/lib/rust/ensogl/core/src/display/scene.rs @@ -306,7 +306,7 @@ pub struct Mouse { pub position: Uniform>, pub hover_ids: Uniform>, pub target: Rc>, - pub handles: Rc<[callback::Handle; 3]>, + pub handles: Rc<[callback::Handle; 4]>, pub frp: enso_frp::io::Mouse, pub scene_frp: Frp, pub logger: Logger, @@ -355,7 +355,10 @@ impl Mouse { current_js_event .make_event_handler(f!((event:&mouse::OnUp) frp.up.emit(event.button()))), ); - let handles = Rc::new([on_move, on_down, on_up]); + let on_wheel = mouse_manager + .on_wheel + .add(current_js_event.make_event_handler(f_!(frp.wheel.emit(())))); + let handles = Rc::new([on_move, on_down, on_up, on_wheel]); Self { mouse_manager, last_position, diff --git a/lib/rust/frp/src/io/js.rs b/lib/rust/frp/src/io/js.rs index fab84e6bea0..0418c75ff2f 100644 --- a/lib/rust/frp/src/io/js.rs +++ b/lib/rust/frp/src/io/js.rs @@ -185,7 +185,7 @@ impl CurrentJsEvent { // asked to. if let Some(e) = current { if !is_passed { - // Prevent events from propagating ot user agent, so default browser actions will + // Prevent events from propagating to user agent, so default browser actions will // not be triggered. e.prevent_default(); e.stop_propagation();