From e84811085eafcf8adc6ac69ffba99dfcd4627f66 Mon Sep 17 00:00:00 2001 From: Gus Wynn Date: Thu, 1 Apr 2021 07:57:05 -0700 Subject: [PATCH] filter mouse buttons --- window/src/os/macos/window.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/window/src/os/macos/window.rs b/window/src/os/macos/window.rs index 298592bf9..0978f4d8b 100644 --- a/window/src/os/macos/window.rs +++ b/window/src/os/macos/window.rs @@ -1497,7 +1497,16 @@ impl WindowView { } extern "C" fn other_mouse_up(this: &mut Object, _sel: Sel, nsevent: id) { - Self::mouse_common(this, nsevent, MouseEventKind::Release(MousePress::Middle)); + // Safety: We know this is an button event + unsafe { + let button_number = NSEvent::buttonNumber(nsevent); + // Button 2 is the middle mouse button (scroll wheel) + // At least on the tested mouse, the dedicated middle mouse button + // is button 4. This should probably be made configurable at some point + if [2, 4].contains(&button_number) { + Self::mouse_common(this, nsevent, MouseEventKind::Release(MousePress::Middle)); + } + } } extern "C" fn scroll_wheel(this: &mut Object, _sel: Sel, nsevent: id) {