Avoid bogus selection events from keys in generic wxDataViewCtrl
Don't do anything and, in particular, don't send any events if pressing a navigation key, such as a cursor up/down arrow, didn't actually change the current item because it was already the first/last one. This fixes an endless stream of wxEVT_DATAVIEW_SELECTION_CHANGED events if the up/down arrow is simply kept pressed when the selection is on first/last item.
This commit is contained in:
@@ -3806,6 +3806,9 @@ void wxDataViewMainWindow::OnVerticalNavigation(const wxKeyEvent& event, int del
|
||||
unsigned int oldCurrent = m_currentRow;
|
||||
unsigned int newCurrent = (unsigned int)newRow;
|
||||
|
||||
if ( newCurrent == oldCurrent )
|
||||
return;
|
||||
|
||||
// in single selection we just ignore Shift as we can't select several
|
||||
// items anyhow
|
||||
if ( event.ShiftDown() && !IsSingleSel() )
|
||||
@@ -3822,14 +3825,12 @@ void wxDataViewMainWindow::OnVerticalNavigation(const wxKeyEvent& event, int del
|
||||
}
|
||||
|
||||
SelectRows(oldCurrent, newCurrent);
|
||||
if (oldCurrent!=newCurrent)
|
||||
{
|
||||
|
||||
wxSelectionStore::IterationState cookie;
|
||||
const unsigned firstSel = m_selection.GetFirstSelectedItem(cookie);
|
||||
if ( firstSel != wxSelectionStore::NO_SELECTION )
|
||||
SendSelectionChangedEvent(GetItemByRow(firstSel));
|
||||
}
|
||||
}
|
||||
else // !shift
|
||||
{
|
||||
RefreshRow( oldCurrent );
|
||||
|
Reference in New Issue
Block a user