Move more code into fj-viewer

This commit is contained in:
Hanno Braun 2024-11-18 20:39:12 +01:00
parent 0ad2699f6d
commit d1854de28b
2 changed files with 3 additions and 9 deletions

View File

@ -121,6 +121,7 @@ impl Viewer {
/// # Handle a mouse button being pressed /// # Handle a mouse button being pressed
pub fn on_mouse_button_pressed(&mut self, button: MouseButton) { pub fn on_mouse_button_pressed(&mut self, button: MouseButton) {
self.most_recent_mouse_button = Some(button); self.most_recent_mouse_button = Some(button);
self.add_focus_point();
} }
/// # Handle a mouse button being pressed /// # Handle a mouse button being pressed
@ -128,6 +129,8 @@ impl Viewer {
if self.most_recent_mouse_button == Some(button) { if self.most_recent_mouse_button == Some(button) {
self.most_recent_mouse_button = None; self.most_recent_mouse_button = None;
} }
self.remove_focus_point();
} }
/// Handle the screen being resized /// Handle the screen being resized

View File

@ -121,15 +121,6 @@ impl ApplicationHandler for DisplayState {
viewer.on_cursor_movement([position.x, position.y]); viewer.on_cursor_movement([position.x, position.y]);
} }
WindowEvent::MouseInput { state, button, .. } => { WindowEvent::MouseInput { state, button, .. } => {
match state {
ElementState::Pressed => {
viewer.add_focus_point();
}
ElementState::Released => {
viewer.remove_focus_point();
}
}
let button = match button { let button = match button {
MouseButton::Left => Some(fj_viewer::MouseButton::Left), MouseButton::Left => Some(fj_viewer::MouseButton::Left),
MouseButton::Right => Some(fj_viewer::MouseButton::Right), MouseButton::Right => Some(fj_viewer::MouseButton::Right),