]> git.saurik.com Git - wxWidgets.git/commitdiff
override DoSetValue() to avoid unnecessary clipboard operations, fixes #14369
authorPaul Cornett <paulcor@bullseye.com>
Sun, 1 Jul 2012 16:43:16 +0000 (16:43 +0000)
committerPaul Cornett <paulcor@bullseye.com>
Sun, 1 Jul 2012 16:43:16 +0000 (16:43 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71917 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/gtk/textentry.h
src/gtk/textentry.cpp

index cc69686650eaf52b40dc5a26a5e699a6badae415..8b47b758e17a6e4c03dbe1045e1b994d4d2f8996 100644 (file)
@@ -52,6 +52,7 @@ public:
     void SendMaxLenEvent();
 
 protected:
+    virtual void DoSetValue(const wxString& value, int flags);
     virtual wxString DoGetValue() const;
 
     // margins functions
index 70e5e591cfb9d9055848448dfe422bccc18228f2..c1badd3203d8d2ecc6ef9dfea0ab7972db362f10 100644 (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));