]> git.saurik.com Git - wxWidgets.git/commitdiff
Forgot about the drag source delegate, which is the perfect place to put GiveFeedback...
authorKevin Ollivier <kevino@theolliviers.com>
Sat, 6 Feb 2010 16:42:44 +0000 (16:42 +0000)
committerKevin Ollivier <kevino@theolliviers.com>
Sat, 6 Feb 2010 16:42:44 +0000 (16:42 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63414 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/osx/cocoa/dnd.mm
src/osx/cocoa/window.mm

index 1345e62b0f013f815f9df88f5ec3c42012489450..74e21d53b0b53a1b9e4eea5e59e9174b3ed8a2fd 100644 (file)
@@ -55,6 +55,7 @@ wxDragResult NSDragOperationToWxDragResult(NSDragOperation code)
 - (void)setImplementation: (wxDropSource *)dropSource;
 - (BOOL)finished;
 - (NSDragOperation)code;
+- (void)draggedImage:(NSImage *)anImage movedTo:(NSPoint)aPoint;
 - (void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation;
 @end
 
@@ -84,6 +85,48 @@ wxDragResult NSDragOperationToWxDragResult(NSDragOperation code)
     return resultCode;
 }
 
+- (void)draggedImage:(NSImage *)anImage movedTo:(NSPoint)aPoint
+{
+    bool optionDown = GetCurrentKeyModifiers() & optionKey;
+    wxDragResult result = optionDown ? wxDragCopy : wxDragMove;
+    
+    if (wxDropSource* source = impl)
+    {
+        if (!source->GiveFeedback(result))
+        {
+            wxStockCursor cursorID = wxCURSOR_NONE;
+
+            switch (result)
+            {
+                case wxDragCopy:
+                    cursorID = wxCURSOR_COPY_ARROW;
+                    break;
+
+                case wxDragMove:
+                    cursorID = wxCURSOR_ARROW;
+                    break;
+
+                case wxDragNone:
+                    cursorID = wxCURSOR_NO_ENTRY;
+                    break;
+
+                case wxDragError:
+                case wxDragLink:
+                case wxDragCancel:
+                default:
+                    // put these here to make gcc happy
+                    ;
+            }
+
+            if (cursorID != wxCURSOR_NONE)
+            {
+                wxCursor cursor( cursorID );
+                cursor.MacInstall();
+            }
+        }
+    }
+}
+
 - (void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation
 {
     resultCode = operation;
index 6d14e6b4591634d6823fd873a15ea17836cd7cd2..3154e3fe2c54b1fae989e475d4f2d88a9adfc34e 100644 (file)
@@ -879,45 +879,6 @@ unsigned int wxWidgetCocoaImpl::draggingUpdated(void* s, WXWidget WXUNUSED(slf),
         result = wxDragCopy;
     else if ( sourceDragMask & NSDragOperationMove )
         result = wxDragMove;
-
-    // FIXME: This doesn't seem the right place for the code, as GiveFeedback
-    // will only get called when the drop target is inside the app itself
-    // but at least some cases will work now.
-    if (wxDropSource* source = wxDropSource::GetCurrentDropSource())
-    {
-        if (!source->GiveFeedback(result))
-        {
-            wxStockCursor cursorID = wxCURSOR_NONE;
-
-            switch (result)
-            {
-                case wxDragCopy:
-                    cursorID = wxCURSOR_COPY_ARROW;
-                    break;
-
-                case wxDragMove:
-                    cursorID = wxCURSOR_ARROW;
-                    break;
-
-                case wxDragNone:
-                    cursorID = wxCURSOR_NO_ENTRY;
-                    break;
-
-                case wxDragError:
-                case wxDragLink:
-                case wxDragCancel:
-                default:
-                    // put these here to make gcc happy
-                    ;
-            }
-
-            if (cursorID != wxCURSOR_NONE)
-            {
-                wxCursor cursor( cursorID );
-                cursor.MacInstall();
-            }
-        }
-    }
     
     PasteboardRef pboardRef;
     PasteboardCreate((CFStringRef)[pboard name], &pboardRef);