From: Kevin Ollivier Date: Sat, 6 Feb 2010 16:42:44 +0000 (+0000) Subject: Forgot about the drag source delegate, which is the perfect place to put GiveFeedback... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/f9022ad20906809c04e65ae764a7c8bc0bf054fe Forgot about the drag source delegate, which is the perfect place to put GiveFeedback related handling. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63414 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/osx/cocoa/dnd.mm b/src/osx/cocoa/dnd.mm index 1345e62b0f..74e21d53b0 100644 --- a/src/osx/cocoa/dnd.mm +++ b/src/osx/cocoa/dnd.mm @@ -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; diff --git a/src/osx/cocoa/window.mm b/src/osx/cocoa/window.mm index 6d14e6b459..3154e3fe2c 100644 --- a/src/osx/cocoa/window.mm +++ b/src/osx/cocoa/window.mm @@ -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);