From 3812e0b58fe97d2b5a8f3a9760f889c99f971e9d Mon Sep 17 00:00:00 2001 From: Imbris Date: Sun, 14 Apr 2019 20:15:12 -0400 Subject: [PATCH] stop zooming when scrolling chat Former-commit-id: a94f26e30029ef4cff1807c2347cbd2490c4afd7 --- voxygen/src/hud/mod.rs | 1 + voxygen/src/ui/mod.rs | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index 4e36a72a4b..2793dfdbe8 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -1540,6 +1540,7 @@ impl Hud { } true } + WinEvent::Zoom(_) => !self.ui.no_widget_capturing_mouse(), WinEvent::KeyDown(Key::Enter) => { if self.typing { self.ui.focus_widget(None); diff --git a/voxygen/src/ui/mod.rs b/voxygen/src/ui/mod.rs index 11ac492547..290f3bc52a 100644 --- a/voxygen/src/ui/mod.rs +++ b/voxygen/src/ui/mod.rs @@ -249,6 +249,7 @@ impl Ui { // Workaround because conrod currently gives us no way to programmatically set which widget is capturing key input // Note the widget must be visible and not covered by other widgets at its center for this to work // Accepts option so widget can be "unfocused" + // TODO: try https://docs.rs/conrod_core/0.63.0/conrod_core/struct.Ui.html#method.keyboard_capture pub fn focus_widget(&mut self, id: Option) { let (x, y) = match id { // get position of widget @@ -272,6 +273,10 @@ impl Ui { ); } + // Get whether the a widget besides the window is capturing the mouse + pub fn no_widget_capturing_mouse(&self) -> bool { + self.ui.global_input().current.widget_capturing_mouse.filter(|id| id != &self.ui.window ).is_none() + } pub fn handle_event(&mut self, event: Event) { match event.0 {