Improve selection and focus events generation in wxGenericLisCtrl

Avoid sending spurious wxEVT_LIST_ITEM_{FOCUSED, SELECTED, DESELECTED}
events and make the generic version consistent with the behaviour of the
native wxMSW one.

Also add/extend the tests and slightly improve the sample.

Closes https://github.com/wxWidgets/wxWidgets/pull/2044
This commit is contained in:
ali kettab
2020-09-06 00:53:45 +01:00
committed by Vadim Zeitlin
parent 80a3cd2db9
commit fedc80eee3
6 changed files with 432 additions and 99 deletions

View File

@@ -20,6 +20,7 @@
#include "wx/listctrl.h"
#include "listbasetest.h"
#include "testableframe.h"
class ListViewTestCase : public ListBaseTestCase, public CppUnit::TestCase
{
@@ -61,7 +62,8 @@ void ListViewTestCase::setUp()
void ListViewTestCase::tearDown()
{
wxDELETE(m_list);
DeleteTestWindow(m_list);
m_list = NULL;
}
void ListViewTestCase::Selection()
@@ -104,6 +106,8 @@ void ListViewTestCase::Selection()
void ListViewTestCase::Focus()
{
EventCounter focused(m_list, wxEVT_LIST_ITEM_FOCUSED);
m_list->InsertColumn(0, "Column 0");
m_list->InsertItem(0, "Item 0");
@@ -111,10 +115,12 @@ void ListViewTestCase::Focus()
m_list->InsertItem(2, "Item 2");
m_list->InsertItem(3, "Item 3");
CPPUNIT_ASSERT_EQUAL(0, focused.GetCount());
CPPUNIT_ASSERT_EQUAL(-1, m_list->GetFocusedItem());
m_list->Focus(0);
CPPUNIT_ASSERT_EQUAL(1, focused.GetCount());
CPPUNIT_ASSERT_EQUAL(0, m_list->GetFocusedItem());
}