From 63f84de849c26e11c9de8295d3cdf52b1d089936 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 16 May 2006 23:53:55 +0000 Subject: [PATCH] reset the dirty flag before generating the event from SetValue() in case the text didn't really change git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39170 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/textctrl.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index 4230d68033..d893afe8d5 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -791,20 +791,24 @@ void wxTextCtrl::SetValue(const wxString& value) { DoWriteText(value, false /* not selection only */); + // mark the control as being not dirty - we changed its text, not the + // user + DiscardEdits(); + // for compatibility, don't move the cursor when doing SetValue() SetInsertionPoint(0); } else // same text { + // still reset the modified flag even if the value didn't really change + // because now it comes from the program and not the user (and do it + // before generating the event so that the event handler could get the + // expected value from IsModified()) + DiscardEdits(); + // still send an event for consistency SendUpdateEvent(); } - - // we should reset the modified flag even if the value didn't really change - - // mark the control as being not dirty - we changed its text, not the - // user - DiscardEdits(); } #if wxUSE_RICHEDIT && (!wxUSE_UNICODE || wxUSE_UNICODE_MSLU) -- 2.45.2