This patch adds extra checks, checks to see and report
if the provided item index is valid.
An other thing:
- IMHO wxComboBox::GetSelection() was wrong, I
corrected this (now it behaves the same as wxMSW,
don't know about wxGTK and others...).
Hans Van Leemputten (hansvl)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18142
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
void wxComboBox::Clear()
{
GetLBox()->Clear();
void wxComboBox::Clear()
{
GetLBox()->Clear();
+ GetText()->SetValue(wxEmptyString);
}
void wxComboBox::Delete(int n)
{
}
void wxComboBox::Delete(int n)
{
+ wxCHECK_RET( (n >= 0) && (n < GetCount()), _T("invalid index in wxComboBox::Delete") );
+
+ if (GetSelection() == n)
+ GetText()->SetValue(wxEmptyString);
+
wxString wxComboBox::GetString(int n) const
{
wxString wxComboBox::GetString(int n) const
{
+ wxCHECK_MSG( (n >= 0) && (n < GetCount()), wxEmptyString, _T("invalid index in wxComboBox::GetString") );
+
return GetLBox()->GetString(n);
}
void wxComboBox::SetString(int n, const wxString& s)
{
return GetLBox()->GetString(n);
}
void wxComboBox::SetString(int n, const wxString& s)
{
+ wxCHECK_RET( (n >= 0) && (n < GetCount()), _T("invalid index in wxComboBox::SetString") );
+
GetLBox()->SetString(n, s);
}
GetLBox()->SetString(n, s);
}
void wxComboBox::Select(int n)
{
void wxComboBox::Select(int n)
{
- wxCHECK_RET( (n >= 0) && (n < GetCount()), _T("invalid combobox index") );
+ wxCHECK_RET( (n >= 0) && (n < GetCount()), _T("invalid index in wxComboBox::Select") );
GetLBox()->SetSelection(n);
GetText()->SetValue(GetLBox()->GetString(n));
GetLBox()->SetSelection(n);
GetText()->SetValue(GetLBox()->GetString(n));
int wxComboBox::GetSelection() const
{
int wxComboBox::GetSelection() const
{
+#if 1 // FIXME:: What is the correct behavior?
// if the current value isn't one of the listbox strings, return -1
// if the current value isn't one of the listbox strings, return -1
+ return GetLBox()->GetSelection();
+#else
+ // Why oh why is this done this way?
+ // It is not because the value displayed in the text can be found
+ // in the list that it is the item that is selected!
return FindString(GetText()->GetValue());
return FindString(GetText()->GetValue());
}
int wxComboBox::DoAppend(const wxString& item)
}
int wxComboBox::DoAppend(const wxString& item)