Don't send events from wxTextCtrl::ChangeValue("") in wxGTK

ChangeValue() must not send events, but did in wxGTK when changing the
contents of a wxTextCtrl to be empty when it had been non-empty before.

Closes #18264.
This commit is contained in:
Vadim Zeitlin
2018-10-31 22:58:26 +01:00
parent 5ee0edde99
commit 8e817f8a0e
3 changed files with 22 additions and 3 deletions

View File

@@ -559,10 +559,20 @@ void wxTextEntry::DoSetValue(const wxString& value, int flags)
EventsSuppressor noevents(this);
Remove(0, -1);
}
EventsSuppressor noeventsIf(this, !(flags & SetValue_SendEvent));
WriteText(value);
// Testing whether value is empty here is more than just an
// optimization: WriteText() always generates an explicit event in
// wxGTK, which we need to avoid unless SetValue_SendEvent is given.
if ( !value.empty() )
{
// Suppress events from here even if we do need them, it's simpler
// to send the event below in all cases.
EventsSuppressor noevents(this);
WriteText(value);
}
}
else if (flags & SetValue_SendEvent)
if ( flags & SetValue_SendEvent )
SendTextUpdatedEvent(GetEditableWindow());
SetInsertionPoint(0);