Check if DnD is started from a mouse event.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43429 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -39,13 +39,16 @@ extern bool g_blockEventsOnDrag;
|
||||
// the flags used for the last DoDragDrop()
|
||||
static long gs_flagsForDrag = 0;
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
// the trace mask we use with wxLogTrace() - call
|
||||
// wxLog::AddTraceMask(TRACE_DND) to enable the trace messages from here
|
||||
// (there are quite a few of them, so don't enable this by default)
|
||||
static const wxChar *TRACE_DND = _T("dnd");
|
||||
#endif
|
||||
|
||||
// global variables because GTK+ DnD want to have the
|
||||
// mouse event that caused it
|
||||
extern GdkEvent *g_lastMouseEvent;
|
||||
|
||||
extern int g_lastButtonNumber;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -835,6 +838,14 @@ wxDragResult wxDropSource::DoDragDrop(int flags)
|
||||
if (g_blockEventsOnDrag)
|
||||
return wxDragNone;
|
||||
|
||||
// don't start dragging if no button is down
|
||||
if (g_lastButtonNumber == 0)
|
||||
return wxDragNone;
|
||||
|
||||
// we can only start a drag after a mouse event
|
||||
if (g_lastMouseEvent == NULL)
|
||||
return wxDragNone;
|
||||
|
||||
// disabled for now
|
||||
g_blockEventsOnDrag = true;
|
||||
|
||||
@@ -855,9 +866,6 @@ wxDragResult wxDropSource::DoDragDrop(int flags)
|
||||
}
|
||||
delete[] array;
|
||||
|
||||
/* don't start dragging if no button is down */
|
||||
if (g_lastButtonNumber)
|
||||
{
|
||||
int action = GDK_ACTION_COPY;
|
||||
if ( flags & wxDrag_AllowMove )
|
||||
action |= GDK_ACTION_MOVE;
|
||||
@@ -883,7 +891,6 @@ wxDragResult wxDropSource::DoDragDrop(int flags)
|
||||
m_retValue = ConvertFromGTK(context->action);
|
||||
if ( m_retValue == wxDragNone )
|
||||
m_retValue = wxDragCancel;
|
||||
}
|
||||
|
||||
g_blockEventsOnDrag = false;
|
||||
|
||||
|
@@ -210,7 +210,8 @@ wxWindowGTK *g_focusWindowLast = (wxWindowGTK*) NULL;
|
||||
// yet, defer setting the focus to idle time.
|
||||
wxWindowGTK *g_delayedFocus = (wxWindowGTK*) NULL;
|
||||
|
||||
// Save the last mouse event for drag start
|
||||
// global variables because GTK+ DnD want to have the
|
||||
// mouse event that caused it
|
||||
GdkEvent *g_lastMouseEvent = (GdkEvent*) NULL;
|
||||
int g_lastButtonNumber = 0;
|
||||
|
||||
@@ -1607,8 +1608,10 @@ gtk_window_button_press_callback( GtkWidget *widget,
|
||||
|
||||
if (win->GTKProcessEvent( event ))
|
||||
{
|
||||
g_lastMouseEvent = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
g_lastMouseEvent = NULL;
|
||||
|
||||
if (event_type == wxEVT_RIGHT_DOWN)
|
||||
{
|
||||
@@ -1749,7 +1752,11 @@ gtk_window_motion_notify_callback( GtkWidget *widget,
|
||||
}
|
||||
}
|
||||
|
||||
return win->GTKProcessEvent(event);
|
||||
bool ret = win->GTKProcessEvent(event);
|
||||
|
||||
g_lastMouseEvent = NULL;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user