From 3e50405b5fe0a15000ad9e6bf3815a94048a696b Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Mon, 12 Nov 2018 23:18:08 +0100 Subject: [PATCH] Update index of selected item of wxOwnerDrawnComboBox popup on inserting new item We have to update index of the currently selected item if value of inserted item is the same as the value of currently selected item (we take lower index in this case) or if new item is inserted before the current selection (current selection index has to be increased in this case). Closes #14153. --- src/generic/odcombo.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/generic/odcombo.cpp b/src/generic/odcombo.cpp index 4f144bb751..8ae5075e20 100644 --- a/src/generic/odcombo.cpp +++ b/src/generic/odcombo.cpp @@ -515,11 +515,13 @@ void wxVListBoxComboPopup::OnChar(wxKeyEvent& event) void wxVListBoxComboPopup::Insert( const wxString& item, int pos ) { // Need to change selection? - wxString strValue; - if ( !(m_combo->GetWindowStyle() & wxCB_READONLY) && - m_combo->GetValue() == item ) + if ( m_combo->GetValue() == item ) { - m_value = pos; + m_value = wxMin(m_value, pos); + } + else if ( pos <= m_value ) + { + m_value++; } m_strings.Insert(item,pos);