From 9572bf1d442006beba3528dc00c3fc05eb523c24 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Mon, 16 Aug 2010 17:48:28 +0000 Subject: [PATCH] Ignore non-existant string selection in wxComboBox::SetValue() in read-only mode, as per the very exact docs, fixes #12329: wxComboBox can set non-existing string in read only mode git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65324 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/combobox.h | 2 ++ src/gtk/combobox.cpp | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/include/wx/gtk/combobox.h b/include/wx/gtk/combobox.h index df97c6bfcc..fb718013c5 100644 --- a/include/wx/gtk/combobox.h +++ b/include/wx/gtk/combobox.h @@ -101,6 +101,8 @@ public: void OnChar( wxKeyEvent &event ); + virtual void SetValue(const wxString& value); + // Standard event handling void OnCut(wxCommandEvent& event); void OnCopy(wxCommandEvent& event); diff --git a/src/gtk/combobox.cpp b/src/gtk/combobox.cpp index 69c1373dde..8ff0dc6b79 100644 --- a/src/gtk/combobox.cpp +++ b/src/gtk/combobox.cpp @@ -276,6 +276,14 @@ wxComboBox::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant)) return GetDefaultAttributesFromGTKWidget(gtk_combo_box_entry_new, true); } +void wxComboBox::SetValue(const wxString& value) +{ + if ( HasFlag(wxCB_READONLY) ) + SetStringSelection(value); + else + wxTextEntry::SetValue(value); +} + // ---------------------------------------------------------------------------- // standard event handling // ---------------------------------------------------------------------------- -- 2.45.2