From b526f9d64d63028d749998fea1ce407439c779f8 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 12 Jul 2010 22:50:14 +0000 Subject: [PATCH] Fix text updated event generation in wxGTK wxComboBox. The changes (cosmetic renaming, no less) in r64436 broke unit tests checking for wxComboBox event generation because the extra text updated events were not suppressed correctly any longer because wrong {Enable,Disable}Events() were called instead of the correct GTK{Enable,Disable}Events(). Fix and slightly improve the code by disabling the events in overridden EnableTextChangedEvents() itself and reuse its code from GTK-specific event enabling functions. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64916 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/combobox.h | 8 +------- src/gtk/combobox.cpp | 23 ++++++++++++++++++----- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/include/wx/gtk/combobox.h b/include/wx/gtk/combobox.h index b126e1c2ca..df97c6bfcc 100644 --- a/include/wx/gtk/combobox.h +++ b/include/wx/gtk/combobox.h @@ -146,13 +146,7 @@ private: // From wxTextEntry: virtual wxWindow *GetEditableWindow() { return this; } virtual GtkEditable *GetEditable() const; - virtual void EnableTextChangedEvents(bool enable) - { - if ( enable ) - EnableEvents(); - else - DisableEvents(); - } + virtual void EnableTextChangedEvents(bool enable); void Init(); diff --git a/src/gtk/combobox.cpp b/src/gtk/combobox.cpp index 1743505cac..69c1373dde 100644 --- a/src/gtk/combobox.cpp +++ b/src/gtk/combobox.cpp @@ -222,11 +222,26 @@ void wxComboBox::OnChar( wxKeyEvent &event ) event.Skip(); } -void wxComboBox::GTKDisableEvents() +void wxComboBox::EnableTextChangedEvents(bool enable) { - if ( GetEntry() ) + if ( !GetEntry() ) + return; + + if ( enable ) + { + g_signal_handlers_unblock_by_func(GTK_BIN(m_widget)->child, + (gpointer)gtkcombobox_text_changed_callback, this); + } + else // disable + { g_signal_handlers_block_by_func(GTK_BIN(m_widget)->child, (gpointer)gtkcombobox_text_changed_callback, this); + } +} + +void wxComboBox::GTKDisableEvents() +{ + EnableTextChangedEvents(false); g_signal_handlers_block_by_func(m_widget, (gpointer)gtkcombobox_changed_callback, this); @@ -236,9 +251,7 @@ void wxComboBox::GTKDisableEvents() void wxComboBox::GTKEnableEvents() { - if ( GetEntry() ) - g_signal_handlers_unblock_by_func(GTK_BIN(m_widget)->child, - (gpointer)gtkcombobox_text_changed_callback, this); + EnableTextChangedEvents(true); g_signal_handlers_unblock_by_func(m_widget, (gpointer)gtkcombobox_changed_callback, this); -- 2.45.2