Apply combobox patch II.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32464 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling 2005-02-28 14:45:58 +00:00
parent fa51336154
commit 4e1a9bc7c9
2 changed files with 12 additions and 10 deletions

View File

@ -38,7 +38,7 @@ extern bool g_isIdle;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
extern bool g_blockEventsOnDrag; extern bool g_blockEventsOnDrag;
static int g_SelectionBeforePopup = -1; static int g_SelectionBeforePopup = -2; // -2 <=> the popup is hidden
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// "changed" - typing and list item matches get changed, select-child // "changed" - typing and list item matches get changed, select-child
// if it doesn't match an item then just get a single changed // if it doesn't match an item then just get a single changed
@ -83,14 +83,15 @@ gtk_popup_hide_callback(GtkCombo *WXUNUSED(gtk_combo), wxComboBox *combo)
combo->GetEventHandler()->ProcessEvent( event ); combo->GetEventHandler()->ProcessEvent( event );
} }
// reset the selection flag to an identifiable value // reset the selection flag to an identifiable value (-2 = hidden)
g_SelectionBeforePopup = -1; g_SelectionBeforePopup = -2;
} }
static void static void
gtk_popup_show_callback(GtkCombo *WXUNUSED(gtk_combo), wxComboBox *combo) gtk_popup_show_callback(GtkCombo *WXUNUSED(gtk_combo), wxComboBox *combo)
{ {
// store the combobox selection value before the popup is shown // store the combobox selection value before the popup is shown
// if there is no selection, combo->GetSelection() returns -1
g_SelectionBeforePopup = combo->GetSelection(); g_SelectionBeforePopup = combo->GetSelection();
} }
@ -125,12 +126,12 @@ gtk_combo_select_child_callback( GtkList *WXUNUSED(list), GtkWidget *WXUNUSED(wi
gtk_signal_connect_after( GTK_OBJECT(GTK_COMBO(combo->GetHandle())->entry), "changed", gtk_signal_connect_after( GTK_OBJECT(GTK_COMBO(combo->GetHandle())->entry), "changed",
GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)combo ); GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)combo );
// throw a SELECTED event only if the combobox popup is hidden // throw a SELECTED event only if the combobox popup is hidden (-2)
// because when combobox popup is shown, gtk_combo_select_child_callback is // because when combobox popup is shown, gtk_combo_select_child_callback is
// called each times the mouse is over an item with a pressed button so a lot // called each times the mouse is over an item with a pressed button so a lot
// of SELECTED event could be generated if the user keep the mouse button down // of SELECTED event could be generated if the user keep the mouse button down
// and select other items ... // and select other items ...
if (g_SelectionBeforePopup == -1) if (g_SelectionBeforePopup == -2)
{ {
wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, combo->GetId() ); wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, combo->GetId() );
event.SetInt( curSelection ); event.SetInt( curSelection );

View File

@ -38,7 +38,7 @@ extern bool g_isIdle;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
extern bool g_blockEventsOnDrag; extern bool g_blockEventsOnDrag;
static int g_SelectionBeforePopup = -1; static int g_SelectionBeforePopup = -2; // -2 <=> the popup is hidden
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// "changed" - typing and list item matches get changed, select-child // "changed" - typing and list item matches get changed, select-child
// if it doesn't match an item then just get a single changed // if it doesn't match an item then just get a single changed
@ -83,14 +83,15 @@ gtk_popup_hide_callback(GtkCombo *WXUNUSED(gtk_combo), wxComboBox *combo)
combo->GetEventHandler()->ProcessEvent( event ); combo->GetEventHandler()->ProcessEvent( event );
} }
// reset the selection flag to an identifiable value // reset the selection flag to an identifiable value (-2 = hidden)
g_SelectionBeforePopup = -1; g_SelectionBeforePopup = -2;
} }
static void static void
gtk_popup_show_callback(GtkCombo *WXUNUSED(gtk_combo), wxComboBox *combo) gtk_popup_show_callback(GtkCombo *WXUNUSED(gtk_combo), wxComboBox *combo)
{ {
// store the combobox selection value before the popup is shown // store the combobox selection value before the popup is shown
// if there is no selection, combo->GetSelection() returns -1
g_SelectionBeforePopup = combo->GetSelection(); g_SelectionBeforePopup = combo->GetSelection();
} }
@ -125,12 +126,12 @@ gtk_combo_select_child_callback( GtkList *WXUNUSED(list), GtkWidget *WXUNUSED(wi
gtk_signal_connect_after( GTK_OBJECT(GTK_COMBO(combo->GetHandle())->entry), "changed", gtk_signal_connect_after( GTK_OBJECT(GTK_COMBO(combo->GetHandle())->entry), "changed",
GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)combo ); GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)combo );
// throw a SELECTED event only if the combobox popup is hidden // throw a SELECTED event only if the combobox popup is hidden (-2)
// because when combobox popup is shown, gtk_combo_select_child_callback is // because when combobox popup is shown, gtk_combo_select_child_callback is
// called each times the mouse is over an item with a pressed button so a lot // called each times the mouse is over an item with a pressed button so a lot
// of SELECTED event could be generated if the user keep the mouse button down // of SELECTED event could be generated if the user keep the mouse button down
// and select other items ... // and select other items ...
if (g_SelectionBeforePopup == -1) if (g_SelectionBeforePopup == -2)
{ {
wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, combo->GetId() ); wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, combo->GetId() );
event.SetInt( curSelection ); event.SetInt( curSelection );