diff --git a/include/wx/listbox.h b/include/wx/listbox.h index 01f64a7ab1..d2332d5d13 100644 --- a/include/wx/listbox.h +++ b/include/wx/listbox.h @@ -122,7 +122,7 @@ protected: wxArrayInt m_oldSelections; // Update m_oldSelections with currently selected items (does nothing in - // single selection mode). + // single selection mode on platforms other than MSW). void UpdateOldSelections(); private: diff --git a/src/common/lboxcmn.cpp b/src/common/lboxcmn.cpp index f7d4fb91a8..8787130451 100644 --- a/src/common/lboxcmn.cpp +++ b/src/common/lboxcmn.cpp @@ -86,8 +86,15 @@ void wxListBoxBase::DeselectAll(int itemToLeaveSelected) void wxListBoxBase::UpdateOldSelections() { + // We need to remember the selection even in single-selection case on + // Windows, so that we don't send an event when the user clicks on an + // already selected item. +#ifndef __WXMSW__ if (HasFlag(wxLB_MULTIPLE) || HasFlag(wxLB_EXTENDED)) +#endif + { GetSelections( m_oldSelections ); + } } bool wxListBoxBase::SendEvent(wxEventType evtType, int item, bool selected)