don't allow setting readonly combobox value to a string which is not one of the valid choices in wxGTK neither and document this behaviour (closes #10549)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59372 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -82,6 +82,8 @@ public:
|
|||||||
Window identifier. The value wxID_ANY indicates a default value.
|
Window identifier. The value wxID_ANY indicates a default value.
|
||||||
@param value
|
@param value
|
||||||
Initial selection string. An empty string indicates no selection.
|
Initial selection string. An empty string indicates no selection.
|
||||||
|
Notice that for the controls with @c wxCB_READONLY style this
|
||||||
|
string must be one of the valid choices if it is not empty.
|
||||||
@param pos
|
@param pos
|
||||||
Window position.
|
Window position.
|
||||||
@param size
|
@param size
|
||||||
|
@@ -136,10 +136,20 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
|
|||||||
|
|
||||||
if ( entry )
|
if ( entry )
|
||||||
{
|
{
|
||||||
gtk_entry_set_text( entry, wxGTK_CONV(value) );
|
|
||||||
|
|
||||||
if (style & wxCB_READONLY)
|
if (style & wxCB_READONLY)
|
||||||
|
{
|
||||||
|
// this will assert and do nothing if the value is not in our list
|
||||||
|
// of strings which is the desired behaviour (for consistency with
|
||||||
|
// wxMSW and also because it doesn't make sense to have a string
|
||||||
|
// which is not a possible choice in a read-only combobox)
|
||||||
|
SetStringSelection(value);
|
||||||
gtk_entry_set_editable( entry, FALSE );
|
gtk_entry_set_editable( entry, FALSE );
|
||||||
|
}
|
||||||
|
else // editable combobox
|
||||||
|
{
|
||||||
|
// any value is accepted, even if it's not in our list
|
||||||
|
gtk_entry_set_text( entry, wxGTK_CONV(value) );
|
||||||
|
}
|
||||||
|
|
||||||
g_signal_connect_after (entry, "changed",
|
g_signal_connect_after (entry, "changed",
|
||||||
G_CALLBACK (gtkcombobox_text_changed_callback), this);
|
G_CALLBACK (gtkcombobox_text_changed_callback), this);
|
||||||
|
Reference in New Issue
Block a user