Fix selection when wxOwnerDrawnComboBox contains identical items
Ensure that the drop-down selection is correct even if there are multiple items with the same label in wxOwnerDrawnComboBox. See https://github.com/wxWidgets/wxWidgets/pull/2544 Closes #19289.
This commit is contained in:
committed by
Vadim Zeitlin
parent
e8a15050d2
commit
6fb64da922
@@ -704,10 +704,20 @@ int wxVListBoxComboPopup::GetSelection() const
|
||||
|
||||
void wxVListBoxComboPopup::SetStringValue( const wxString& value )
|
||||
{
|
||||
int index = m_strings.Index(value);
|
||||
|
||||
m_stringValue = value;
|
||||
|
||||
// Keep previous selection if it already corresponds to the given value
|
||||
// (this is useful if there are multiple identical items in the combobox,
|
||||
// we don't want to select the first one of them if another one had been
|
||||
// previously selected).
|
||||
if ( m_value >= 0 && m_value < (int)m_strings.size() &&
|
||||
value == m_strings[m_value] )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int index = m_strings.Index(value);
|
||||
|
||||
if ( index >= 0 && index < (int)wxVListBox::GetItemCount() )
|
||||
{
|
||||
wxVListBox::SetSelection(index);
|
||||
|
Reference in New Issue
Block a user