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
This commit is contained in:
Vadim Zeitlin
2013-03-04 18:19:41 +00:00
parent 09f84bc716
commit 11e3c6ef36

View File

@@ -4010,20 +4010,24 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event )
return; 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(); event.Skip();
return; return;
} }
wxDataViewRenderer *cell = col->GetRenderer(); wxDataViewRenderer *cell = col->GetRenderer();
if ((current >= GetRowCount()) || (x > GetEndOfLastCol()))
{
// Unselect all if below the last row ?
event.Skip();
return;
}
wxDataViewColumn* const wxDataViewColumn* const
expander = GetExpanderColumnOrFirstOne(GetOwner()); expander = GetExpanderColumnOrFirstOne(GetOwner());