]> git.saurik.com Git - wxWidgets.git/commitdiff
Unselect all wxDataViewCtrl items when clicking outside of the item area.
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 4 Mar 2013 18:19:41 +0000 (18:19 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 4 Mar 2013 18:19:41 +0000 (18:19 +0000)
This is consistent with Windows behaviour and as the generic wxDataViewCtrl is
mostly used under Windows, it makes sense to follow Windows convention in it.

Closes #15082.

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

src/generic/datavgen.cpp

index 631cfecd76b675b31af74c20bf828a14dc53d551..8d09cf5b524f79f7328d9a17a87d6855f48b2684 100644 (file)
@@ -4010,20 +4010,24 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event )
         return;
     }
 
-    if (!col)
+    // Check if we clicked outside the item area.
+    if ((current >= GetRowCount()) || !col)
     {
+        // Follow Windows convention here: clicking either left or right (but
+        // not middle) button clears the existing selection.
+        if (m_owner && (event.LeftDown() || event.RightDown()))
+        {
+            if (!GetSelections().empty())
+            {
+                m_owner->UnselectAll();
+                SendSelectionChangedEvent(wxDataViewItem());
+            }
+        }
         event.Skip();
         return;
     }
 
     wxDataViewRenderer *cell = col->GetRenderer();
-    if ((current >= GetRowCount()) || (x > GetEndOfLastCol()))
-    {
-        // Unselect all if below the last row ?
-        event.Skip();
-        return;
-    }
-
     wxDataViewColumn* const
         expander = GetExpanderColumnOrFirstOne(GetOwner());