From 189aedd89a89ca76401cedce4baca129a357ec97 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 6 Feb 2016 01:46:17 +0100 Subject: [PATCH] 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. --- src/generic/datavgen.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 6b9324d6e4..2394ce2116 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -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,13 +3825,11 @@ 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)); - } + + wxSelectionStore::IterationState cookie; + const unsigned firstSel = m_selection.GetFirstSelectedItem(cookie); + if ( firstSel != wxSelectionStore::NO_SELECTION ) + SendSelectionChangedEvent(GetItemByRow(firstSel)); } else // !shift {