From 6caba72637a9d9240124c33a1c753b9b86e8cc17 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 21 Jul 2019 21:32:16 +0200 Subject: [PATCH 1/3] Remove redundant wxCommandEvent::SetEventObject() call No real changes, just don't call SetEventObject() already called from InitCommandEventWithItems() (via InitCommandEvent()). --- src/common/ctrlsub.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/common/ctrlsub.cpp b/src/common/ctrlsub.cpp index afba9ce85b..d9ba02cd4c 100644 --- a/src/common/ctrlsub.cpp +++ b/src/common/ctrlsub.cpp @@ -299,7 +299,6 @@ void wxControlWithItemsBase::SendSelectionChangedEvent(wxEventType eventType) wxCommandEvent event(eventType, m_windowId); event.SetInt(n); - event.SetEventObject(this); event.SetString(GetStringSelection()); InitCommandEventWithItems(event, n); From cd8dade23c29f11c5334bf7adcdb4056aacd533c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 21 Jul 2019 21:37:05 +0200 Subject: [PATCH 2/3] Set event string field for wxOwnerDrawnComboBox events Call wxCommandEvent::SetString() for consistency with the native wxComboBox. --- src/generic/odcombo.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/generic/odcombo.cpp b/src/generic/odcombo.cpp index 156facae6c..1891540a1a 100644 --- a/src/generic/odcombo.cpp +++ b/src/generic/odcombo.cpp @@ -238,6 +238,8 @@ void wxVListBoxComboPopup::SendComboBoxEvent( int selection ) evt.SetEventObject(m_combo); evt.SetInt(selection); + if ( selection != wxNOT_FOUND ) + evt.SetString(m_strings[selection]); // Set client data, if any if ( selection >= 0 && (int)m_clientDatas.size() > selection ) From 366233e4009729ed9f8ccb4e8e7007bfa7bf4e03 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 21 Jul 2019 21:38:59 +0200 Subject: [PATCH 3/3] Add a TODO comment for wxVListBox refactoring Just note that it would be better to avoid duplicating the code already existing in another place in wxVListBoxComboPopup::SendComboBoxEvent(). --- src/generic/odcombo.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/generic/odcombo.cpp b/src/generic/odcombo.cpp index 1891540a1a..fd3061e414 100644 --- a/src/generic/odcombo.cpp +++ b/src/generic/odcombo.cpp @@ -233,6 +233,11 @@ void wxVListBoxComboPopup::DismissWithEvent() void wxVListBoxComboPopup::SendComboBoxEvent( int selection ) { + // TODO: wxVListBox should be refactored to inherit from wxItemContainer + // and then we would be able to just call SendSelectionChangedEvent() + // (which, itself, should be moved down to wxItemContainer from + // wxControlWithItemsBase) instead of duplicating its code. + wxCommandEvent evt(wxEVT_COMBOBOX,m_combo->GetId()); evt.SetEventObject(m_combo);