Don't move wxTextCtrl insertion point if it doesn't really change
Resetting the insertion point position to 0 after calling wxTextCtrl::SetValue() or ChangeValue() which didn't really change the control contents was unexpected, as such calls are supposed to be "optimized away", and this was indeed the case under wxMSW and wxOSX, but not in wxGTK. So change wxGTK to follow the other ports, add a unit test checking for this behaviour and officially document it. As a side effect, this ensures that the numeric validator classes don't reset the insertion point position to 0 on every focus loss under wxGTK, as happened before.
This commit is contained in:
@@ -165,6 +165,12 @@ void TextEntryTestCase::InsertionPoint()
|
||||
CPPUNIT_ASSERT_EQUAL( 3, entry->GetLastPosition() );
|
||||
CPPUNIT_ASSERT_EQUAL( 1, entry->GetInsertionPoint() );
|
||||
|
||||
entry->SetValue("012"); // shouldn't change the position if no real change
|
||||
CPPUNIT_ASSERT_EQUAL( 1, entry->GetInsertionPoint() );
|
||||
|
||||
entry->ChangeValue("012"); // same as for SetValue()
|
||||
CPPUNIT_ASSERT_EQUAL( 1, entry->GetInsertionPoint() );
|
||||
|
||||
entry->SetInsertionPointEnd();
|
||||
CPPUNIT_ASSERT_EQUAL( 3, entry->GetInsertionPoint() );
|
||||
|
||||
|
Reference in New Issue
Block a user