From cd84abe8229046de261ca8b8a9dd52c40f068c85 Mon Sep 17 00:00:00 2001 From: mgalos999 Date: Sun, 25 Sep 2022 01:45:28 +1000 Subject: [PATCH] mouse passthrough option --- crates/eframe/src/epi.rs | 5 +++++ crates/eframe/src/native/run.rs | 3 +++ 2 files changed, 8 insertions(+) diff --git a/crates/eframe/src/epi.rs b/crates/eframe/src/epi.rs index 278f5a177f1c..b3cd25180bc7 100644 --- a/crates/eframe/src/epi.rs +++ b/crates/eframe/src/epi.rs @@ -270,6 +270,10 @@ pub struct NativeOptions { /// You should avoid having a [`egui::CentralPanel`], or make sure its frame is also transparent. pub transparent: bool, + /// On desktop: mouse clicks pass through the window, used for non-interactable overlays + /// Generally you would use this in conjunction with always_on_top + pub mouse_passthrough: bool, + /// Turn on vertical syncing, limiting the FPS to the display refresh rate. /// /// The default is `true`. @@ -389,6 +393,7 @@ impl Default for NativeOptions { max_window_size: None, resizable: true, transparent: false, + mouse_passthrough: false, vsync: true, multisampling: 0, depth_buffer: 0, diff --git a/crates/eframe/src/native/run.rs b/crates/eframe/src/native/run.rs index 77c75e2d0d7c..5690ea9ddd16 100644 --- a/crates/eframe/src/native/run.rs +++ b/crates/eframe/src/native/run.rs @@ -383,6 +383,9 @@ mod glow_integration { integration.egui_ctx.set_visuals(theme.egui_visuals()); gl_window.window().set_ime_allowed(true); + if self.native_options.mouse_passthrough { + gl_window.window().set_cursor_hittest(false).unwrap(); + } { let event_loop_proxy = self.repaint_proxy.clone();