]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix dnd events in generic wxDataViewCtrl when moving out of the window.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 29 Jun 2013 12:51:24 +0000 (12:51 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 29 Jun 2013 12:51:24 +0000 (12:51 +0000)
The wxEVT_DATAVIEW_ITEM_BEGIN_DRAG event wasn't triggered if the mouse moved
below the last item or beyond the last column of a control or left the window
completely.

Fix this by checking for the beginning of the drag before checking for the
mouse being out of items area and also force the drag to start if the mouse is
leaving the window as we would never do it otherwise.

Closes #15258.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74308 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/generic/datavgen.cpp

index f5f7d7b1e565f7561e42e8aa5e6e690a2abe6c50..8d66c6d05923f36d20d4c036fe04774cc6638e95 100644 (file)
@@ -4062,6 +4062,58 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event )
         return;
     }
 
         return;
     }
 
+#if wxUSE_DRAG_AND_DROP
+    if (event.Dragging() || ((m_dragCount > 0) && event.Leaving()))
+    {
+        if (m_dragCount == 0)
+        {
+            // we have to report the raw, physical coords as we want to be
+            // able to call HitTest(event.m_pointDrag) from the user code to
+            // get the item being dragged
+            m_dragStart = event.GetPosition();
+        }
+
+        m_dragCount++;
+        if ((m_dragCount < 3) && (event.Leaving()))
+            m_dragCount = 3;
+        else if (m_dragCount != 3)
+            return;
+
+        if (event.LeftIsDown())
+        {
+            m_owner->CalcUnscrolledPosition( m_dragStart.x, m_dragStart.y,
+                                             &m_dragStart.x, &m_dragStart.y );
+            unsigned int drag_item_row = GetLineAt( m_dragStart.y );
+            wxDataViewItem itemDragged = GetItemByRow( drag_item_row );
+
+            // Notify cell about drag
+            wxDataViewEvent event( wxEVT_DATAVIEW_ITEM_BEGIN_DRAG, m_owner->GetId() );
+            event.SetEventObject( m_owner );
+            event.SetItem( itemDragged );
+            event.SetModel( model );
+            if (!m_owner->HandleWindowEvent( event ))
+                return;
+
+            if (!event.IsAllowed())
+                return;
+
+            wxDataObject *obj = event.GetDataObject();
+            if (!obj)
+                return;
+
+            wxDataViewDropSource drag( this, drag_item_row );
+            drag.SetData( *obj );
+            /* wxDragResult res = */ drag.DoDragDrop(event.GetDragFlags());
+            delete obj;
+        }
+        return;
+    }
+    else
+    {
+        m_dragCount = 0;
+    }
+#endif // wxUSE_DRAG_AND_DROP
+
     // Check if we clicked outside the item area.
     if ((current >= GetRowCount()) || !col)
     {
     // Check if we clicked outside the item area.
     if ((current >= GetRowCount()) || !col)
     {
@@ -4135,57 +4187,6 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event )
         }
     }
 
         }
     }
 
-#if wxUSE_DRAG_AND_DROP
-    if (event.Dragging())
-    {
-        if (m_dragCount == 0)
-        {
-            // we have to report the raw, physical coords as we want to be
-            // able to call HitTest(event.m_pointDrag) from the user code to
-            // get the item being dragged
-            m_dragStart = event.GetPosition();
-        }
-
-        m_dragCount++;
-
-        if (m_dragCount != 3)
-            return;
-
-        if (event.LeftIsDown())
-        {
-            m_owner->CalcUnscrolledPosition( m_dragStart.x, m_dragStart.y,
-                                             &m_dragStart.x, &m_dragStart.y );
-            unsigned int drag_item_row = GetLineAt( m_dragStart.y );
-            wxDataViewItem itemDragged = GetItemByRow( drag_item_row );
-
-            // Notify cell about drag
-            wxDataViewEvent event( wxEVT_DATAVIEW_ITEM_BEGIN_DRAG, m_owner->GetId() );
-            event.SetEventObject( m_owner );
-            event.SetItem( itemDragged );
-            event.SetModel( model );
-            if (!m_owner->HandleWindowEvent( event ))
-                return;
-
-            if (!event.IsAllowed())
-                return;
-
-            wxDataObject *obj = event.GetDataObject();
-            if (!obj)
-                return;
-
-            wxDataViewDropSource drag( this, drag_item_row );
-            drag.SetData( *obj );
-            /* wxDragResult res = */ drag.DoDragDrop(event.GetDragFlags());
-            delete obj;
-        }
-        return;
-    }
-    else
-    {
-        m_dragCount = 0;
-    }
-#endif // wxUSE_DRAG_AND_DROP
-
     bool simulateClick = false;
 
     if (event.ButtonDClick())
     bool simulateClick = false;
 
     if (event.ButtonDClick())