From 2b51c146091064103046efedd18639a085a01b5e Mon Sep 17 00:00:00 2001 From: Andy Robinson Date: Sat, 5 Dec 2020 23:44:57 +0100 Subject: [PATCH] Ignore events from unknown buttons in wxOSX In particular, don't map them to left mouse clicks because this is really wrong. Ideal would be to handle them in some way, but for now just throwing them away is better than generating wrong events. Closes #18967. --- src/osx/cocoa/window.mm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/osx/cocoa/window.mm b/src/osx/cocoa/window.mm index 467998f485..619915b4d9 100644 --- a/src/osx/cocoa/window.mm +++ b/src/osx/cocoa/window.mm @@ -1470,6 +1470,26 @@ void wxWidgetCocoaImpl::mouseEvent(WX_NSEvent event, WXWidget slf, void *_cmd) return; } + // The Infinity IN-USB-2 V15 foot pedal on OS 11 produces spurious mouse + // button events with button number = 10. + // We cannot do anything useful with button numbers > 2, so throw them away. + switch ( [event type] ) + { + case NSLeftMouseDown: + case NSRightMouseDown: + case NSOtherMouseDown: + case NSLeftMouseUp: + case NSRightMouseUp: + case NSOtherMouseUp: + if ( [event buttonNumber] > 2 ) + return; + break; + + default: + // Just to avoid -Wswitch. + break; + } + if ( !DoHandleMouseEvent(event) ) { // for plain NSView mouse events would propagate to parents otherwise