diff --git a/include/wx/gtk/textctrl.h b/include/wx/gtk/textctrl.h index 0d5c118934..da2f70bbbd 100644 --- a/include/wx/gtk/textctrl.h +++ b/include/wx/gtk/textctrl.h @@ -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; diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index 1b08ecc0a8..9517877940 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -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);