Don't generate events from wxSpinCtrl::SetRange() in wxMSW.

Other ports don't send wxEVT_COMMAND_SPINCTRL_UPDATED from SetRange() even if
the value changed because it was adjusted to fit into the new range and this
makes sense as this change is not due to a user action, so don't send this
event under wxMSW neither.

Also add a unit test checking for this behaviour.

Closes #14583.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72341 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-08-15 23:34:10 +00:00
parent 947873e263
commit 532324df23
4 changed files with 26 additions and 1 deletions

View File

@@ -165,7 +165,18 @@ void SpinCtrlTestCase::Range()
CPPUNIT_ASSERT_EQUAL(0, m_spin->GetMin());
CPPUNIT_ASSERT_EQUAL(100, m_spin->GetMax());
//Test neagtive ranges
// Test that the value is adjusted to be inside the new valid range but
// that this doesn't result in any events (as this is not something done by
// the user).
{
EventCounter updated(m_spin, wxEVT_COMMAND_SPINCTRL_UPDATED);
m_spin->SetRange(1, 10);
CPPUNIT_ASSERT_EQUAL(1, m_spin->GetValue());
CPPUNIT_ASSERT_EQUAL(0, updated.GetCount());
}
//Test negative ranges
m_spin->SetRange(-10, 10);
CPPUNIT_ASSERT_EQUAL(-10, m_spin->GetMin());