From d1854de28ba56ded1cd966370f41677d84f03796 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 18 Nov 2024 20:39:12 +0100 Subject: [PATCH] Move more code into `fj-viewer` --- crates/fj-viewer/src/viewer.rs | 3 +++ crates/fj-window/src/display.rs | 9 --------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/crates/fj-viewer/src/viewer.rs b/crates/fj-viewer/src/viewer.rs index 415b6c83d..640e6aee5 100644 --- a/crates/fj-viewer/src/viewer.rs +++ b/crates/fj-viewer/src/viewer.rs @@ -121,6 +121,7 @@ impl Viewer { /// # Handle a mouse button being pressed pub fn on_mouse_button_pressed(&mut self, button: MouseButton) { self.most_recent_mouse_button = Some(button); + self.add_focus_point(); } /// # Handle a mouse button being pressed @@ -128,6 +129,8 @@ impl Viewer { if self.most_recent_mouse_button == Some(button) { self.most_recent_mouse_button = None; } + + self.remove_focus_point(); } /// Handle the screen being resized diff --git a/crates/fj-window/src/display.rs b/crates/fj-window/src/display.rs index 76198ab8e..efd22f7cc 100644 --- a/crates/fj-window/src/display.rs +++ b/crates/fj-window/src/display.rs @@ -121,15 +121,6 @@ impl ApplicationHandler for DisplayState { viewer.on_cursor_movement([position.x, position.y]); } WindowEvent::MouseInput { state, button, .. } => { - match state { - ElementState::Pressed => { - viewer.add_focus_point(); - } - ElementState::Released => { - viewer.remove_focus_point(); - } - } - let button = match button { MouseButton::Left => Some(fj_viewer::MouseButton::Left), MouseButton::Right => Some(fj_viewer::MouseButton::Right),