From 11e3c6ef36393fb5863ea2f9601d8facd73acb12 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 4 Mar 2013 18:19:41 +0000 Subject: [PATCH] Unselect all wxDataViewCtrl items when clicking outside of the item area. 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 | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 631cfecd76..8d09cf5b52 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -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()); -- 2.45.2