]> git.saurik.com Git - wxWidgets.git/commitdiff
decouple item index from string value (patch 1905702)
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 2 Mar 2008 14:55:43 +0000 (14:55 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 2 Mar 2008 14:55:43 +0000 (14:55 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52254 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/odcombo.h
src/generic/odcombo.cpp

index 7efe58f9e4776b31c81fceb947a899a6422986d7..fe124347397cc21c6fa81da41c0435127e7cfa56 100644 (file)
@@ -212,6 +212,8 @@ private:
     // Partial completion string
     wxString                m_partialCompletionString;
 
+    wxString                m_stringValue;
+
 #if wxUSE_TIMER
     // Partial completion timer
     wxTimer                 m_partialCompletionTimer;
index dc9234fc7f14c66087a256faf04dcfc4db4d0bfd..d79d692b18799668d5af6e24e5e502ebef9ef92a 100644 (file)
@@ -209,16 +209,15 @@ 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;
 
-    m_value = selection;
+    if ( m_stringValue != m_combo->GetValue() )
+        m_combo->SetValueWithEvent(m_stringValue);
 
-    if ( valStr != m_combo->GetValue() )
-        m_combo->SetValueWithEvent(valStr);
+    m_value = selection;
 
     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()