]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/cocoa/dnd.mm
make sure mouse moved events are always delivered, see #15008
[wxWidgets.git] / src / osx / cocoa / dnd.mm
index ae860ad50eb44f033c1fba1cd94998099642b80b..c12e16f5b957c3b81fc2a0fc6002f7dba1e68fce 100644 (file)
@@ -4,13 +4,17 @@
 // Author:      Stefan Csomor
 // Modified by:
 // Created:     1998-01-01
-// RCS-ID:      $Id: dnd.cpp 61724 2009-08-21 10:41:26Z VZ $
+// RCS-ID:      $Id$
 // Copyright:   (c) 1998 Stefan Csomor
 // Licence:     wxWindows licence
 ///////////////////////////////////////////////////////////////////////////////
 
 #include "wx/wxprec.h"
 
+#ifndef WX_PRECOMP
+#include "wx/object.h"
+#endif
+
 #if wxUSE_DRAG_AND_DROP
 
 #include "wx/dnd.h"
@@ -32,6 +36,8 @@ wxDragResult NSDragOperationToWxDragResult(NSDragOperation code)
 {
     switch (code)
     {
+        case NSDragOperationGeneric:
+            return wxDragCopy;
         case NSDragOperationCopy:
             return wxDragCopy;
         case NSDragOperationMove:
@@ -43,6 +49,7 @@ wxDragResult NSDragOperationToWxDragResult(NSDragOperation code)
         default:
             wxFAIL_MSG("Unexpected result code");
     }
+    return wxDragNone;
 }
 
 @interface DropSourceDelegate : NSObject
@@ -63,7 +70,7 @@ wxDragResult NSDragOperationToWxDragResult(NSDragOperation code)
 
 - (id)init
 {
-    [super init];
+    self = [super init];
     dragFinished = NO;
     resultCode = NSDragOperationNone;
     impl = 0;
@@ -213,7 +220,7 @@ wxDragResult wxDropSource::DoDragDrop(int WXUNUSED(flags))
         wxASSERT_MSG(theEvent, "DoDragDrop must be called in response to a mouse down or drag event.");
 
         NSPoint down = [theEvent locationInWindow];
-        NSPoint p = [view convertPoint:down toView:nil];
+        NSPoint p = [view convertPoint:down fromView:nil];
                 
         gCurrentSource = this;
         
@@ -245,6 +252,23 @@ wxDragResult wxDropSource::DoDragDrop(int WXUNUSED(flags))
         result = NSDragOperationToWxDragResult([delegate code]);
         [delegate release];
         [image release];
+        
+        wxWindow* mouseUpTarget = wxWindow::GetCapture();
+
+        if ( mouseUpTarget == NULL )
+        {
+            mouseUpTarget = m_window;
+        }
+        
+        if ( mouseUpTarget != NULL )
+        {
+            wxMouseEvent wxevent(wxEVT_LEFT_DOWN);
+            ((wxWidgetCocoaImpl*)mouseUpTarget->GetPeer())->SetupMouseEvent(wxevent , theEvent) ;
+            wxevent.SetEventType(wxEVT_LEFT_UP);
+        
+            mouseUpTarget->HandleWindowEvent(wxevent);
+        }
+        
         gCurrentSource = NULL;
     }