From 844159792f736fc8f974314a1ca8cedbd43ba948 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 1 Nov 2014 13:56:30 +0000 Subject: [PATCH] Fix clearing wxCB_READONLY wxComboBox in wxGTK. wxComboBox::Clear() must call wxTextEntry::SetValue() explicitly instead of calling its Clear() which just forwards back to wxComboBox own SetValue(), which (correctly) doesn't work for read-only comboboxes when passed an empty string. Closes #16654. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78085 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + src/gtk/combobox.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/changes.txt b/docs/changes.txt index 7269c040ad..cf47256cd3 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -91,6 +91,7 @@ wxGTK: - Support building wxGTK3 under Windows (Kolya Kosenko). - Fix vertical cell alignment in wxDataViewCtrl. +- Fix clearing of wxComboBox with wxCB_READONLY (Chuddah). wxMSW: diff --git a/src/gtk/combobox.cpp b/src/gtk/combobox.cpp index d507865f53..f08cf2b1f8 100644 --- a/src/gtk/combobox.cpp +++ b/src/gtk/combobox.cpp @@ -297,7 +297,12 @@ wxComboBox::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant)) void wxComboBox::Clear() { - wxTextEntry::Clear(); + // Do not call wxTextEntry::Clear() here as it's implemented in terms of + // virtual SetValue() and so would call our own overridden version of this + // method, which wouldn't do the right thing in wxCB_READONLY case. + // + // Clear the text directly to avoid this. + wxTextEntry::SetValue(wxString()); wxItemContainer::Clear(); }