]> git.saurik.com Git - wxWidgets.git/commitdiff
safe degradation
authorStefan Csomor <csomor@advancedconcepts.ch>
Wed, 3 Feb 2010 08:32:42 +0000 (08:32 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Wed, 3 Feb 2010 08:32:42 +0000 (08:32 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63370 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/osx/cocoa/window.mm

index eef2cdf99405684fb167cc165980de63a51584e0..83a5e7f79aae55eb30428c81d180dc4b5b8983df 100644 (file)
@@ -516,19 +516,43 @@ void wxWidgetCocoaImpl::SetupMouseEvent( wxMouseEvent &wxevent , NSEvent * nsEve
 
      case NSScrollWheel :
         {
+            float deltaX = 0.0;
+            float deltaY = 0.0;
+
             wxevent.SetEventType( wxEVT_MOUSEWHEEL ) ;
+
+            // see http://developer.apple.com/qa/qa2005/qa1453.html
+            // for more details on why we have to look for the exact type
+            
+            const EventRef cEvent = (EventRef) [nsEvent eventRef];
+            bool isMouseScrollEvent = false;
+            if ( cEvent )
+                isMouseScrollEvent = ::GetEventKind(cEvent) == kEventMouseScroll;
+                
+            if ( isMouseScrollEvent )
+            {
+                deltaX = [nsEvent deviceDeltaX];
+                deltaY = [nsEvent deviceDeltaY];
+            }
+            else
+            {
+                deltaX = ([nsEvent deltaX] * 10);
+                deltaY = ([nsEvent deltaY] * 10);
+            }
+            
             wxevent.m_wheelDelta = 10;
             wxevent.m_linesPerAction = 1;
-
-            if ( fabs([nsEvent deviceDeltaX]) > fabs([nsEvent deviceDeltaY]) )
+                
+            if ( fabs(deltaX) > fabs(deltaY) )
             {
                 wxevent.m_wheelAxis = 1;
-                wxevent.m_wheelRotation = (int)[nsEvent deviceDeltaX];
+                wxevent.m_wheelRotation = (int)deltaX;
             }
             else
             {
-                wxevent.m_wheelRotation = (int)[nsEvent deviceDeltaY];
+                wxevent.m_wheelRotation = (int)deltaY;
             }
+
         }
         break ;