From 61db1dc0ade7e9d7044369a4f2fc3c061a7215c5 Mon Sep 17 00:00:00 2001 From: follower Date: Tue, 5 Jul 2022 19:42:07 +1200 Subject: [PATCH] Only pass events to input handler if `egui` doesn't want exclusive access. This now seems to work correctly, whereas the last time I tried to implement this functionality it didn't, IIRC. Not sure why but might be because I'm restricting it to affecting the "input handler"-related events only? And/or the `egui` monitored area might be restricted to a narrower part of the window? Anyway, this means that interacting with the UI now doesn't also affect the model view, e.g. mouse drag can change values without *also* rotating model. :) --- crates/fj-window/src/run.rs | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/crates/fj-window/src/run.rs b/crates/fj-window/src/run.rs index dfcd1fb5e..98b4da63d 100644 --- a/crates/fj-window/src/run.rs +++ b/crates/fj-window/src/run.rs @@ -86,6 +86,8 @@ pub fn run( // + let mut egui_wants_exclusive = false; + if let Event::WindowEvent { event: window_event, .. @@ -103,11 +105,12 @@ pub fn run( // a title bar that overlaps the model then both the model & window // get moved. // - // TODO: Revisit this. + // DONE: Revisit this. (Added `egui_wants_exclusive` which actually seems + // to work as expected now.) // // TODO: Encapsulate the egui state/context access better. // - renderer + egui_wants_exclusive = renderer .egui .winit_state .on_event(&renderer.egui.context, &window_event); @@ -240,17 +243,20 @@ pub fn run( _ => None, }; - if let (Some(event), Some(shape), Some(camera)) = - (event, &shape, &mut camera) - { - input_handler.handle_event( - event, - window.size(), - now, - &shape.mesh, - camera, - &mut actions, - ); + if !egui_wants_exclusive { + if let (Some(event), Some(shape), Some(camera)) = + (event, &shape, &mut camera) + { + input_handler.handle_event( + event, + window.size(), + now, + &shape.mesh, + camera, + &mut actions, + ); + } + } } if actions.exit {