Avoid duplicate handling of events (in gui and 3D)
@@ -21,7 +21,7 @@ impl GUI {
})
}
- pub fn render<F: FnOnce(&egui::CtxRef)>(&mut self, frame_input: &FrameInput, callback: F) -> Result<(), Error>
+ pub fn handle_input<F: FnOnce(&egui::CtxRef)>(&mut self, frame_input: &mut FrameInput, callback: F) -> Result<(), Error>
{
let mut scroll_delta = egui::Vec2::ZERO;
let mut egui_modifiers = egui::Modifiers::default();
@@ -88,7 +88,14 @@ impl GUI {
};
self.egui_context.begin_frame(input_state);
callback(&self.egui_context);
+ if self.egui_context.wants_pointer_input() || self.egui_context.wants_keyboard_input() {
+ frame_input.events.clear();
+ }
+ Ok(())
+ }
+ pub fn render(&mut self, frame_input: &FrameInput) -> Result<(), Error>
+ {
let (_, shapes) = self.egui_context.end_frame();
let clipped_meshes = self.egui_context.tessellate(shapes);
