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.
This commit is contained in:
Artur Wieczorek
2018-11-12 23:18:08 +01:00
parent 65ac801c40
commit 3e50405b5f

View File

@@ -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);