]> git.saurik.com Git - wxWidgets.git/commitdiff
fix generation of events from SetValue() broken in rev 46611
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 19 Aug 2007 19:05:56 +0000 (19:05 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 19 Aug 2007 19:05:56 +0000 (19:05 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48183 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

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

index 0d5c1189347824915fc3d4c6400906b56517ac8b..da2f70bbbd6f1fa13368ab1210ff65f6dbc80b26 100644 (file)
@@ -212,7 +212,17 @@ private:
     // encoding
     wxFontEncoding GetTextEncoding() const;
 
+    // returns either m_text or m_buffer depending on whether the control is
+    // single- or multi-line; convenient for the GTK+ functions which work with
+    // both
+    void *GetTextObject() const
+    {
+        return IsMultiLine() ? wx_static_cast(void *, m_buffer)
+                             : wx_static_cast(void *, m_text);
+    }
+
 
+    // the widget used for single line controls
     GtkWidget  *m_text;
 
     bool        m_modified:1;
index 1b08ecc0a8d49d2e91fb2e9f88a429ce433dcde9..9517877940a15cd1fac0c153432e196594425078 100644 (file)
@@ -1018,9 +1018,12 @@ void wxTextCtrl::DoSetValue( const wxString &value, int flags )
         return;
     }
 
-    void* blockWidget = IsMultiLine() ? (void*)m_buffer : (void*)m_text;
-    g_signal_handlers_block_by_func(blockWidget,
-        (gpointer)gtk_text_changed_callback, this);
+    if ( !(flags & SetValue_SendEvent) )
+    {
+        g_signal_handlers_block_by_func(GetTextObject(),
+            (gpointer)gtk_text_changed_callback, this);
+    }
+
     if ( IsMultiLine() )
     {
         gtk_text_buffer_set_text( m_buffer, buffer, strlen(buffer) );
@@ -1033,12 +1036,16 @@ void wxTextCtrl::DoSetValue( const wxString &value, int flags )
                                        &start, &end);
         }
     }
-    else
+    else // single line
     {
         gtk_entry_set_text( GTK_ENTRY(m_text), buffer );
     }
-    g_signal_handlers_unblock_by_func(blockWidget,
-        (gpointer)gtk_text_changed_callback, this);
+
+    if ( !(flags & SetValue_SendEvent) )
+    {
+        g_signal_handlers_unblock_by_func(GetTextObject(),
+            (gpointer)gtk_text_changed_callback, this);
+    }
                     
     // This was added after discussion on the list
     SetInsertionPoint(0);