Fixed bug with SetValue on read-only combobox; don't call ::SetWindowText,
use SetStringSelection instead. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@17018 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -376,9 +376,9 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
|
|||||||
void wxComboBox::SetValue(const wxString& value)
|
void wxComboBox::SetValue(const wxString& value)
|
||||||
{
|
{
|
||||||
// If newlines are denoted by just 10, must stick 13 in front.
|
// If newlines are denoted by just 10, must stick 13 in front.
|
||||||
int singletons = 0;
|
size_t singletons = 0;
|
||||||
int len = value.Length();
|
size_t len = value.Length();
|
||||||
int i;
|
size_t i;
|
||||||
for (i = 0; i < len; i ++)
|
for (i = 0; i < len; i ++)
|
||||||
{
|
{
|
||||||
if ((i > 0) && (value[i] == 10) && (value[i-1] != 13))
|
if ((i > 0) && (value[i] == 10) && (value[i-1] != 13))
|
||||||
@@ -386,8 +386,9 @@ void wxComboBox::SetValue(const wxString& value)
|
|||||||
}
|
}
|
||||||
if (singletons > 0)
|
if (singletons > 0)
|
||||||
{
|
{
|
||||||
wxChar *tmp = new wxChar[len + singletons + 1];
|
wxString tmp;
|
||||||
int j = 0;
|
tmp.Alloc(len + singletons);
|
||||||
|
size_t j = 0;
|
||||||
for (i = 0; i < len; i ++)
|
for (i = 0; i < len; i ++)
|
||||||
{
|
{
|
||||||
if ((i > 0) && (value[i] == 10) && (value[i-1] != 13))
|
if ((i > 0) && (value[i] == 10) && (value[i-1] != 13))
|
||||||
@@ -398,12 +399,16 @@ void wxComboBox::SetValue(const wxString& value)
|
|||||||
tmp[j] = value[i];
|
tmp[j] = value[i];
|
||||||
j ++;
|
j ++;
|
||||||
}
|
}
|
||||||
tmp[j] = 0;
|
if (GetWindowStyle() & wxCB_READONLY)
|
||||||
SetWindowText(GetHwnd(), tmp);
|
SetStringSelection(tmp);
|
||||||
delete[] tmp;
|
else
|
||||||
|
SetWindowText(GetHwnd(), tmp.c_str());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
SetWindowText(GetHwnd(), value);
|
if (GetWindowStyle() & wxCB_READONLY)
|
||||||
|
SetStringSelection(value);
|
||||||
|
else
|
||||||
|
SetWindowText(GetHwnd(), value.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clipboard operations
|
// Clipboard operations
|
||||||
|
Reference in New Issue
Block a user