Fix bug in CanUndo() returning true after wxTextCtrl creation
For wxMSW text controls with wxTE_RICH2 style, calling SetFont() counts as an undoable operation, resulting in CanUndo() returning true even if no "real" changes have been made yet. Fix this by resetting the undo stack after creating the control using ITextDocument::Undo(). Unfortunately this interface is not available in MinGW-32, so this fix can't be used with it. Closes https://github.com/wxWidgets/wxWidgets/pull/2010 Closes #17524.
This commit is contained in:
committed by
Vadim Zeitlin
parent
c1d3e65ac4
commit
a59901f8f1
@@ -1432,4 +1432,35 @@ TEST_CASE("wxTextCtrl::EventsOnCreate", "[wxTextCtrl][event]")
|
||||
CHECK( updated.GetCount() == 1 );
|
||||
}
|
||||
|
||||
TEST_CASE("wxTextCtrl::InitialCanUndo", "[wxTextCtrl][undo]")
|
||||
{
|
||||
wxWindow* const parent = wxTheApp->GetTopWindow();
|
||||
|
||||
const long styles[] = { 0, wxTE_RICH, wxTE_RICH2 };
|
||||
|
||||
for ( size_t n = 0; n < WXSIZEOF(styles); n++ )
|
||||
{
|
||||
const long style = styles[n];
|
||||
|
||||
#ifdef __MINGW32_TOOLCHAIN__
|
||||
if ( style == wxTE_RICH2 )
|
||||
{
|
||||
// We can't call ITextDocument::Undo() in wxMSW code when using
|
||||
// MinGW32, so this test would always fail with it.
|
||||
WARN("Skipping test known to fail with MinGW-32.");
|
||||
}
|
||||
continue;
|
||||
#endif // __MINGW32_TOOLCHAIN__
|
||||
|
||||
INFO("wxTextCtrl with style " << style);
|
||||
|
||||
wxScopedPtr<wxTextCtrl> text(new wxTextCtrl(parent, wxID_ANY, "",
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize,
|
||||
style));
|
||||
|
||||
CHECK( !text->CanUndo() );
|
||||
}
|
||||
}
|
||||
|
||||
#endif //wxUSE_TEXTCTRL
|
||||
|
Reference in New Issue
Block a user