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
This commit is contained in:
Vadim Zeitlin 2010-07-12 22:50:14 +00:00
parent 969641a391
commit b526f9d64d
2 changed files with 19 additions and 12 deletions

View File

@ -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();

View File

@ -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);