fix generation of events from SetValue() broken in rev 46611

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48183 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-08-19 19:05:56 +00:00
parent b7e9f8b136
commit 86e37f69bc
2 changed files with 23 additions and 6 deletions

View File

@@ -212,7 +212,17 @@ private:
// encoding // encoding
wxFontEncoding GetTextEncoding() const; 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; GtkWidget *m_text;
bool m_modified:1; bool m_modified:1;

View File

@@ -1018,9 +1018,12 @@ void wxTextCtrl::DoSetValue( const wxString &value, int flags )
return; return;
} }
void* blockWidget = IsMultiLine() ? (void*)m_buffer : (void*)m_text; if ( !(flags & SetValue_SendEvent) )
g_signal_handlers_block_by_func(blockWidget, {
(gpointer)gtk_text_changed_callback, this); g_signal_handlers_block_by_func(GetTextObject(),
(gpointer)gtk_text_changed_callback, this);
}
if ( IsMultiLine() ) if ( IsMultiLine() )
{ {
gtk_text_buffer_set_text( m_buffer, buffer, strlen(buffer) ); gtk_text_buffer_set_text( m_buffer, buffer, strlen(buffer) );
@@ -1033,12 +1036,16 @@ void wxTextCtrl::DoSetValue( const wxString &value, int flags )
&start, &end); &start, &end);
} }
} }
else else // single line
{ {
gtk_entry_set_text( GTK_ENTRY(m_text), buffer ); 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 // This was added after discussion on the list
SetInsertionPoint(0); SetInsertionPoint(0);