From a614ffae7187a70bf353cc1bbf4873ee65c58e34 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Wed, 25 Aug 2010 15:02:30 +0000 Subject: [PATCH] Fix wxListBox selection handling broken by r64500. r64500 introduced tracking of previous selection in wxMSW's wxListBox so that an event isn't sent when the user clicks already selected item again. Unfortunately, it forgot to account for programatic changes of selection (e.g. when all items are removed, so is the selection) and didn't update selection book-keeping information in that case. The result was that the event wasn't sent when it should be in some cases. Fixed by using UpdateOldSelections() even in single-selection case in wxMSW. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65406 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/listbox.h | 2 +- src/common/lboxcmn.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) 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) -- 2.47.2