return effective dnd operation result and not the expected one (replaces patch 1677399)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44722 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-03-10 16:27:15 +00:00
parent 01ba4b6713
commit 56d152b225

View File

@@ -37,6 +37,8 @@ typedef struct
wxWindow *m_currentTargetWindow; wxWindow *m_currentTargetWindow;
wxDropTarget *m_currentTarget; wxDropTarget *m_currentTarget;
wxDropSource *m_currentSource; wxDropSource *m_currentSource;
wxDragResult m_result;
int m_flags;
} MacTrackingGlobals; } MacTrackingGlobals;
MacTrackingGlobals gTrackingGlobals; MacTrackingGlobals gTrackingGlobals;
@@ -455,18 +457,15 @@ wxDragResult wxDropSource::DoDragDrop(int flags)
// only when drag was successfully completed // only when drag was successfully completed
gTrackingGlobals.m_currentSource = this; gTrackingGlobals.m_currentSource = this;
gTrackingGlobals.m_result = wxDragNone;
gTrackingGlobals.m_flags = flags;
TrackDrag( theDrag, ev, dragRegion ); TrackDrag( theDrag, ev, dragRegion );
DisposeRgn( dragRegion ); DisposeRgn( dragRegion );
DisposeDrag( theDrag ); DisposeDrag( theDrag );
gTrackingGlobals.m_currentSource = NULL; gTrackingGlobals.m_currentSource = NULL;
bool optionDown = GetCurrentKeyModifiers() & optionKey; return gTrackingGlobals.m_result;
wxDragResult dndresult = wxDragCopy;
if ( flags != wxDrag_CopyOnly )
// on mac the option key is always the indication for copy
dndresult = optionDown ? wxDragCopy : wxDragMove;
return dndresult;
} }
bool wxDropSource::MacInstallDefaultCursor(wxDragResult effect) bool wxDropSource::MacInstallDefaultCursor(wxDragResult effect)
@@ -704,13 +703,20 @@ pascal OSErr wxMacWindowDragReceiveHandler(
trackingGlobals->m_currentTargetWindow->MacRootWindowToWindow( &localx, &localy ); trackingGlobals->m_currentTargetWindow->MacRootWindowToWindow( &localx, &localy );
if ( trackingGlobals->m_currentTarget->OnDrop( localx, localy ) ) if ( trackingGlobals->m_currentTarget->OnDrop( localx, localy ) )
{ {
bool optionDown = GetCurrentKeyModifiers() & optionKey; // the option key indicates copy in Mac UI, if it's not pressed do
wxDragResult result = optionDown ? wxDragCopy : wxDragMove; // move by default if it's allowed at all
trackingGlobals->m_currentTarget->OnData( localx, localy, result ); wxDragResult
result = !(trackingGlobals->m_flags & wxDrag_AllowMove) ||
(GetCurrentKeyModifiers() & optionKey)
? wxDragCopy
: wxDragMove;
trackingGlobals->m_result =
trackingGlobals->m_currentTarget->OnData( localx, localy, result );
} }
} }
return noErr; return noErr;
} }
#endif #endif // wxUSE_DRAG_AND_DROP