]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/cocoa/nonownedwnd.mm
reflect correct position for native toolbar, fixes #14049
[wxWidgets.git] / src / osx / cocoa / nonownedwnd.mm
index 229e7442302c71ffbfbd32e23cc403fff3a77c84..81ecf321aa53dfa9a173cc6cbb2b7c8bb439a30b 100644 (file)
@@ -120,12 +120,38 @@ bool shouldHandleSelector(SEL selector)
     bool handled = false;
     if ( ([event type] >= NSLeftMouseDown) && ([event type] <= NSMouseExited) )
     {
+        WXEVENTREF formerEvent = wxTheApp == NULL ? NULL : wxTheApp->MacGetCurrentEvent();
+        WXEVENTHANDLERCALLREF formerHandler = wxTheApp == NULL ? NULL : wxTheApp->MacGetCurrentEventHandlerCallRef();
+
         wxWindow* cw = wxWindow::GetCapture();
         if ( cw != NULL )
         {
+            if (wxTheApp)
+                wxTheApp->MacSetCurrentEvent(event, NULL);
             ((wxWidgetCocoaImpl*)cw->GetPeer())->DoHandleMouseEvent( event);
             handled = true;
         }
+        else if ( [event type] == NSMouseMoved )
+        {
+            NSPoint nsPoint = [event locationInWindow];
+            if ( [event window] != nil )
+                nsPoint = [[event window] convertBaseToScreen:nsPoint];
+
+            wxPoint pt = wxFromNSPoint(NULL, nsPoint);
+            wxWindow* mw = ::wxFindWindowAtPoint(pt);
+            if ( mw )
+            {
+                if (wxTheApp)
+                    wxTheApp->MacSetCurrentEvent(event, NULL);
+                ((wxWidgetCocoaImpl*)mw->GetPeer())->DoHandleMouseEvent( event);
+                handled = true;
+            }
+        }
+        if ( handled )
+        {
+            if (wxTheApp)
+                wxTheApp->MacSetCurrentEvent(formerEvent , formerHandler);
+        }
     }
     return handled;
 }
@@ -241,7 +267,18 @@ bool shouldHandleSelector(SEL selector)
 - (void)sendEvent:(NSEvent *) event
 {
     if ( ![self WX_filterSendEvent: event] )
+    {
+        WXEVENTREF formerEvent = wxTheApp == NULL ? NULL : wxTheApp->MacGetCurrentEvent();
+        WXEVENTHANDLERCALLREF formerHandler = wxTheApp == NULL ? NULL : wxTheApp->MacGetCurrentEventHandlerCallRef();
+        
+        if (wxTheApp)
+            wxTheApp->MacSetCurrentEvent(event, NULL);
+        
         [super sendEvent: event];
+        
+        if (wxTheApp)
+            wxTheApp->MacSetCurrentEvent(formerEvent , formerHandler);
+    }
 }
 
 @end
@@ -455,8 +492,8 @@ extern int wxOSXGetIdFromSelector(SEL action );
             [editor release];
         }
         return editor;
-    }
-
+    } 
     return nil;
 }