decouple item index from string value (patch 1905702)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52254 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -212,6 +212,8 @@ private:
|
||||
// Partial completion string
|
||||
wxString m_partialCompletionString;
|
||||
|
||||
wxString m_stringValue;
|
||||
|
||||
#if wxUSE_TIMER
|
||||
// Partial completion timer
|
||||
wxTimer m_partialCompletionTimer;
|
||||
|
@@ -209,17 +209,16 @@ void wxVListBoxComboPopup::DismissWithEvent()
|
||||
|
||||
Dismiss();
|
||||
|
||||
wxString valStr;
|
||||
if ( selection != wxNOT_FOUND )
|
||||
valStr = m_strings[selection];
|
||||
m_stringValue = m_strings[selection];
|
||||
else
|
||||
valStr = wxEmptyString;
|
||||
m_stringValue = wxEmptyString;
|
||||
|
||||
if ( m_stringValue != m_combo->GetValue() )
|
||||
m_combo->SetValueWithEvent(m_stringValue);
|
||||
|
||||
m_value = selection;
|
||||
|
||||
if ( valStr != m_combo->GetValue() )
|
||||
m_combo->SetValueWithEvent(valStr);
|
||||
|
||||
SendComboBoxEvent(selection);
|
||||
}
|
||||
|
||||
@@ -609,9 +608,7 @@ void wxVListBoxComboPopup::SetString( int item, const wxString& str )
|
||||
|
||||
wxString wxVListBoxComboPopup::GetStringValue() const
|
||||
{
|
||||
if ( m_value >= 0 )
|
||||
return m_strings[m_value];
|
||||
return wxEmptyString;
|
||||
return m_stringValue;
|
||||
}
|
||||
|
||||
void wxVListBoxComboPopup::SetSelection( int item )
|
||||
@@ -621,6 +618,11 @@ void wxVListBoxComboPopup::SetSelection( int item )
|
||||
|
||||
m_value = item;
|
||||
|
||||
if ( item >= 0 )
|
||||
m_stringValue = m_strings[item];
|
||||
else
|
||||
m_stringValue = wxEmptyString;
|
||||
|
||||
if ( IsCreated() )
|
||||
wxVListBox::SetSelection(item);
|
||||
}
|
||||
@@ -634,10 +636,13 @@ void wxVListBoxComboPopup::SetStringValue( const wxString& value )
|
||||
{
|
||||
int index = m_strings.Index(value);
|
||||
|
||||
m_value = index;
|
||||
m_stringValue = value;
|
||||
|
||||
if ( index >= -1 && index < (int)wxVListBox::GetItemCount() )
|
||||
if ( index >= 0 && index < (int)wxVListBox::GetItemCount() )
|
||||
{
|
||||
wxVListBox::SetSelection(index);
|
||||
m_value = index;
|
||||
}
|
||||
}
|
||||
|
||||
void wxVListBoxComboPopup::CalcWidths()
|
||||
|
Reference in New Issue
Block a user