]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/choice.cpp
Store pointer to owning wxWindow in wxPizza widget
[wxWidgets.git] / src / msw / choice.cpp
index 9eec9c2332422433a5166bbbd315c221a5af77cb..14a10703bc375d8139cfa45e4dc3fee57265f0d7 100644 (file)
@@ -158,6 +158,21 @@ bool wxChoice::CreateAndInit(wxWindow *parent,
     return true;
 }
 
+void wxChoice::SetLabel(const wxString& label)
+{
+    if ( FindString(label) == wxNOT_FOUND )
+    {
+        // unless we explicitly do this here, CB_GETCURSEL will continue to
+        // return the index of the previously selected item which will result
+        // in wrongly replacing the value being set now with the previously
+        // value if the user simply opens and closes (without selecting
+        // anything) the combobox popup
+        SetSelection(-1);
+    }
+
+    wxChoiceBase::SetLabel(label);
+}
+
 bool wxChoice::Create(wxWindow *parent,
                       wxWindowID id,
                       const wxPoint& pos,
@@ -688,13 +703,6 @@ bool wxChoice::MSWCommand(WXUINT param, WXWORD WXUNUSED(id))
             // need to reset the selection back to it if it's eventually
             // cancelled by user
             m_lastAcceptedSelection = GetCurrentSelection();
-            if ( m_lastAcceptedSelection == -1 )
-            {
-                // no current selection so no need to restore it later (this
-                // happens when opening a combobox containing text not from its
-                // list of items and we shouldn't erase this text)
-                m_lastAcceptedSelection = wxID_NONE;
-            }
             break;
 
         case CBN_CLOSEUP: