|
|
@ -498,7 +498,7 @@ fn install_canvas_events(runner_ref: &AppRunnerRef) -> Result<(), JsValue> { |
|
|
|
let closure = Closure::wrap(Box::new(move |event: web_sys::MouseEvent| { |
|
|
|
let mut runner_lock = runner_ref.0.lock(); |
|
|
|
if !runner_lock.input.is_touch { |
|
|
|
runner_lock.input.mouse_pos = |
|
|
|
runner_lock.input.raw.mouse_pos = |
|
|
|
Some(pos_from_mouse_event(runner_lock.canvas_id(), &event)); |
|
|
|
runner_lock.input.raw.mouse_down = true; |
|
|
|
runner_lock.logic().unwrap(); // in case we get "mouseup" the same frame. TODO: handle via events instead
|
|
|
@ -517,7 +517,7 @@ fn install_canvas_events(runner_ref: &AppRunnerRef) -> Result<(), JsValue> { |
|
|
|
let closure = Closure::wrap(Box::new(move |event: web_sys::MouseEvent| { |
|
|
|
let mut runner_lock = runner_ref.0.lock(); |
|
|
|
if !runner_lock.input.is_touch { |
|
|
|
runner_lock.input.mouse_pos = |
|
|
|
runner_lock.input.raw.mouse_pos = |
|
|
|
Some(pos_from_mouse_event(runner_lock.canvas_id(), &event)); |
|
|
|
runner_lock.needs_repaint.set_true(); |
|
|
|
event.stop_propagation(); |
|
|
@ -534,7 +534,7 @@ fn install_canvas_events(runner_ref: &AppRunnerRef) -> Result<(), JsValue> { |
|
|
|
let closure = Closure::wrap(Box::new(move |event: web_sys::MouseEvent| { |
|
|
|
let mut runner_lock = runner_ref.0.lock(); |
|
|
|
if !runner_lock.input.is_touch { |
|
|
|
runner_lock.input.mouse_pos = |
|
|
|
runner_lock.input.raw.mouse_pos = |
|
|
|
Some(pos_from_mouse_event(runner_lock.canvas_id(), &event)); |
|
|
|
runner_lock.input.raw.mouse_down = false; |
|
|
|
runner_lock.needs_repaint.set_true(); |
|
|
@ -552,7 +552,7 @@ fn install_canvas_events(runner_ref: &AppRunnerRef) -> Result<(), JsValue> { |
|
|
|
let closure = Closure::wrap(Box::new(move |event: web_sys::MouseEvent| { |
|
|
|
let mut runner_lock = runner_ref.0.lock(); |
|
|
|
if !runner_lock.input.is_touch { |
|
|
|
runner_lock.input.mouse_pos = None; |
|
|
|
runner_lock.input.raw.mouse_pos = None; |
|
|
|
runner_lock.needs_repaint.set_true(); |
|
|
|
event.stop_propagation(); |
|
|
|
event.prevent_default(); |
|
|
@ -568,7 +568,7 @@ fn install_canvas_events(runner_ref: &AppRunnerRef) -> Result<(), JsValue> { |
|
|
|
let closure = Closure::wrap(Box::new(move |event: web_sys::TouchEvent| { |
|
|
|
let mut runner_lock = runner_ref.0.lock(); |
|
|
|
runner_lock.input.is_touch = true; |
|
|
|
runner_lock.input.mouse_pos = Some(pos_from_touch_event(&event)); |
|
|
|
runner_lock.input.raw.mouse_pos = Some(pos_from_touch_event(&event)); |
|
|
|
runner_lock.input.raw.mouse_down = true; |
|
|
|
runner_lock.needs_repaint.set_true(); |
|
|
|
event.stop_propagation(); |
|
|
@ -584,7 +584,7 @@ fn install_canvas_events(runner_ref: &AppRunnerRef) -> Result<(), JsValue> { |
|
|
|
let closure = Closure::wrap(Box::new(move |event: web_sys::TouchEvent| { |
|
|
|
let mut runner_lock = runner_ref.0.lock(); |
|
|
|
runner_lock.input.is_touch = true; |
|
|
|
runner_lock.input.mouse_pos = Some(pos_from_touch_event(&event)); |
|
|
|
runner_lock.input.raw.mouse_pos = Some(pos_from_touch_event(&event)); |
|
|
|
runner_lock.needs_repaint.set_true(); |
|
|
|
event.stop_propagation(); |
|
|
|
event.prevent_default(); |
|
|
@ -601,7 +601,7 @@ fn install_canvas_events(runner_ref: &AppRunnerRef) -> Result<(), JsValue> { |
|
|
|
runner_lock.input.is_touch = true; |
|
|
|
runner_lock.input.raw.mouse_down = false; // First release mouse to click...
|
|
|
|
runner_lock.logic().unwrap(); // ...do the clicking... (TODO: handle via events instead)
|
|
|
|
runner_lock.input.mouse_pos = None; // ...remove hover effect
|
|
|
|
runner_lock.input.raw.mouse_pos = None; // ...remove hover effect
|
|
|
|
runner_lock.needs_repaint.set_true(); |
|
|
|
event.stop_propagation(); |
|
|
|
event.prevent_default(); |
|
|
@ -615,8 +615,8 @@ fn install_canvas_events(runner_ref: &AppRunnerRef) -> Result<(), JsValue> { |
|
|
|
let runner_ref = runner_ref.clone(); |
|
|
|
let closure = Closure::wrap(Box::new(move |event: web_sys::WheelEvent| { |
|
|
|
let mut runner_lock = runner_ref.0.lock(); |
|
|
|
runner_lock.input.scroll_delta.x -= event.delta_x() as f32; |
|
|
|
runner_lock.input.scroll_delta.y -= event.delta_y() as f32; |
|
|
|
runner_lock.input.raw.scroll_delta.x -= event.delta_x() as f32; |
|
|
|
runner_lock.input.raw.scroll_delta.y -= event.delta_y() as f32; |
|
|
|
runner_lock.needs_repaint.set_true(); |
|
|
|
event.stop_propagation(); |
|
|
|
event.prevent_default(); |
|
|
|