]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/combocmn.cpp
Forward declare classes instead of including their declarations.
[wxWidgets.git] / src / common / combocmn.cpp
index 53f8b308491a61415895236c138169a73c038a54..0b3a518a1b22ec7331f01bca321b574773c0c7a0 100644 (file)
@@ -590,6 +590,12 @@ void wxComboPopup::SetStringValue( const wxString& WXUNUSED(value) )
 {
 }
 
+bool wxComboPopup::FindItem(const wxString& WXUNUSED(item),
+                            wxString* WXUNUSED(trueItem))
+{
+    return true;
+}
+
 bool wxComboPopup::LazyCreate()
 {
     return false;
@@ -2575,12 +2581,26 @@ void wxComboCtrlBase::OnSetValue(const wxString& value)
     // to set the string value here (as well as sometimes in ShowPopup).
     if ( m_valueString != value )
     {
-        m_valueString = value;
+        bool found = true;
+        wxString trueValue = value;
+
+        // Conform to wxComboBox behavior: read-only control can only accept
+        // valid list items and empty string
+        if ( m_popupInterface && HasFlag(wxCB_READONLY) && value.length() )
+        {
+            found = m_popupInterface->FindItem(value,
+                                               &trueValue);
+        }
 
-        EnsurePopupControl();
+        if ( found )
+        {
+            m_valueString = trueValue;
 
-        if (m_popupInterface)
-            m_popupInterface->SetStringValue(value);
+            EnsurePopupControl();
+
+            if ( m_popupInterface )
+                m_popupInterface->SetStringValue(trueValue);
+        }
     }
 
     Refresh();