Document wxItemContainer::SetStringSelection() as case-insensitive.
Add unit tests checking that the behaviour really corresponds to the documentation too. And also mention that it's not a good idea to have strings differing by case only in wxComboBox anyhow. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66442 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
1db02a5e5c
commit
3256418982
@ -23,7 +23,10 @@
|
||||
|
||||
Please refer to wxTextEntry documentation for the description of methods
|
||||
operating with the text entry part of the combobox and to wxItemContainer
|
||||
for the methods operating with the list of strings.
|
||||
for the methods operating with the list of strings. Notice that at least
|
||||
under MSW wxComboBox doesn't behave correctly if it contains strings
|
||||
differing in case only so portable programs should avoid adding such
|
||||
strings to this control.
|
||||
|
||||
@beginStyleTable
|
||||
@style{wxCB_SIMPLE}
|
||||
|
@ -123,12 +123,17 @@ public:
|
||||
virtual int GetSelection() const = 0;
|
||||
|
||||
/**
|
||||
Selects the item with the specified string in the control. This doesn't
|
||||
cause any command events to be emitted.
|
||||
Selects the item with the specified string in the control.
|
||||
|
||||
This method doesn't cause any command events to be emitted.
|
||||
|
||||
Notice that this method is case-insensitive, i.e. the string is
|
||||
compared with all the elements of the control case-insensitively and
|
||||
the first matching entry is selected, even if it doesn't have exactly
|
||||
the same case as this string and there is an exact match afterwards.
|
||||
|
||||
@param string
|
||||
The string to select.
|
||||
|
||||
@return @true if the specified string has been selected, @false if it
|
||||
wasn't found in the control.
|
||||
*/
|
||||
|
@ -105,22 +105,27 @@ void ItemContainerTestCase::ItemSelection()
|
||||
testitems.Add("item 0");
|
||||
testitems.Add("item 1");
|
||||
testitems.Add("item 2");
|
||||
testitems.Add("item 3");
|
||||
testitems.Add("ITEM 2"); // The same as the last one except for case.
|
||||
|
||||
container->Append(testitems);
|
||||
|
||||
container->SetSelection(wxNOT_FOUND);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(wxNOT_FOUND, container->GetSelection());
|
||||
CPPUNIT_ASSERT_EQUAL("", container->GetStringSelection());
|
||||
|
||||
container->SetSelection(1);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, container->GetSelection());
|
||||
CPPUNIT_ASSERT_EQUAL("item 1", container->GetStringSelection());
|
||||
|
||||
container->SetStringSelection("item 2");
|
||||
CPPUNIT_ASSERT( container->SetStringSelection("item 2") );
|
||||
CPPUNIT_ASSERT_EQUAL(2, container->GetSelection());
|
||||
CPPUNIT_ASSERT_EQUAL("item 2", container->GetStringSelection());
|
||||
|
||||
// Check that selecting a non-existent item fails.
|
||||
CPPUNIT_ASSERT( !container->SetStringSelection("bloordyblop") );
|
||||
|
||||
// Check that SetStringSelection() is case-insensitive.
|
||||
CPPUNIT_ASSERT( container->SetStringSelection("ITEM 2") );
|
||||
CPPUNIT_ASSERT_EQUAL(2, container->GetSelection());
|
||||
CPPUNIT_ASSERT_EQUAL("item 2", container->GetStringSelection());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user