override DoSetValue() to avoid unnecessary clipboard operations, fixes #14369

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71917 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Paul Cornett 2012-07-01 16:43:16 +00:00
parent 14de8214d6
commit 7537769845
2 changed files with 21 additions and 0 deletions

View File

@ -52,6 +52,7 @@ public:
void SendMaxLenEvent();
protected:
virtual void DoSetValue(const wxString& value, int flags);
virtual wxString DoGetValue() const;
// margins functions

View File

@ -110,6 +110,26 @@ void wxTextEntry::WriteText(const wxString& value)
gtk_editable_set_position(edit, len);
}
void wxTextEntry::DoSetValue(const wxString& value, int flags)
{
if (value != GetValue())
{
// use Remove() rather than SelectAll() to avoid unnecessary clipboard
// operations, and prevent triggering an apparent bug in GTK which
// causes the the subsequent WriteText() to append rather than overwrite
{
EventsSuppressor noevents(this);
Remove(0, -1);
}
EventsSuppressor noeventsIf(this, !(flags & SetValue_SendEvent));
WriteText(value);
}
else if (flags & SetValue_SendEvent)
SendTextUpdatedEvent(GetEditableWindow());
SetInsertionPoint(0);
}
wxString wxTextEntry::DoGetValue() const
{
const wxGtkString value(gtk_editable_get_chars(GetEditable(), 0, -1));