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());