From 9a5bffb8ab50c4b96ad33d6585f3c9ebfe237912 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Fri, 28 Feb 2003 00:23:09 +0000 Subject: [PATCH] Next take at combobox. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@19377 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/combobox.cpp | 46 ++++++++++++++++--------------------------- src/gtk1/combobox.cpp | 46 ++++++++++++++++--------------------------- 2 files changed, 34 insertions(+), 58 deletions(-) diff --git a/src/gtk/combobox.cpp b/src/gtk/combobox.cpp index 152d8b530e..11ae1afc3d 100644 --- a/src/gtk/combobox.cpp +++ b/src/gtk/combobox.cpp @@ -35,7 +35,8 @@ extern bool g_isIdle; extern bool g_blockEventsOnDrag; -static bool gs_typedSelection = FALSE; +static wxComboBox *gs_lastCombo = NULL; +static wxString gs_lastString; //----------------------------------------------------------------------------- // "select-child" - click/cursor get select-child, changed, select-child @@ -50,32 +51,26 @@ gtk_combo_select_child_callback( GtkList *WXUNUSED(list), GtkWidget *WXUNUSED(wi if (g_blockEventsOnDrag) return; - if (!gs_typedSelection) - { - - if (combo->m_alreadySent) - { - combo->m_alreadySent = FALSE; - return; - } - - combo->m_alreadySent = TRUE; - } - else - { - gs_typedSelection = FALSE; - } - int curSelection = combo->GetSelection(); - + if (combo->m_prevSelection != curSelection) { GtkWidget *list = GTK_COMBO(combo->m_widget)->list; gtk_list_unselect_item( GTK_LIST(list), combo->m_prevSelection ); } - combo->m_prevSelection = curSelection; + if ((combo == gs_lastCombo) && + (combo->GetStringSelection() == gs_lastString)) + { + return; + } + else + { + gs_lastCombo = combo; + gs_lastString = combo->GetStringSelection(); + } + wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, combo->GetId() ); event.SetInt( curSelection ); event.SetString( combo->GetStringSelection() ); @@ -85,7 +80,7 @@ gtk_combo_select_child_callback( GtkList *WXUNUSED(list), GtkWidget *WXUNUSED(wi } //----------------------------------------------------------------------------- -// "changed" - typing and list item matches get changed, select-child, changed +// "changed" - typing and list item matches get changed, select-child // if it doesn't match an item then just get a single changed //----------------------------------------------------------------------------- @@ -96,15 +91,6 @@ gtk_text_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo ) if (!combo->m_hasVMT) return; - if ((combo->FindString(combo->GetValue()) != wxNOT_FOUND) && !combo->m_alreadySent) - { - gs_typedSelection = TRUE; - - // Do we send a TEXT_UPDATE event if we send a CMOBOBOX event - // anyways? I think so. - // return; - } - wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, combo->GetId() ); event.SetString( combo->GetValue() ); event.SetEventObject( combo ); @@ -405,6 +391,8 @@ int wxComboBox::FindString( const wxString &item ) #else wxString str( label->label ); #endif + wxPrintf( L"Item %s\n", str.c_str() ); + if (item == str) return count; diff --git a/src/gtk1/combobox.cpp b/src/gtk1/combobox.cpp index 152d8b530e..11ae1afc3d 100644 --- a/src/gtk1/combobox.cpp +++ b/src/gtk1/combobox.cpp @@ -35,7 +35,8 @@ extern bool g_isIdle; extern bool g_blockEventsOnDrag; -static bool gs_typedSelection = FALSE; +static wxComboBox *gs_lastCombo = NULL; +static wxString gs_lastString; //----------------------------------------------------------------------------- // "select-child" - click/cursor get select-child, changed, select-child @@ -50,32 +51,26 @@ gtk_combo_select_child_callback( GtkList *WXUNUSED(list), GtkWidget *WXUNUSED(wi if (g_blockEventsOnDrag) return; - if (!gs_typedSelection) - { - - if (combo->m_alreadySent) - { - combo->m_alreadySent = FALSE; - return; - } - - combo->m_alreadySent = TRUE; - } - else - { - gs_typedSelection = FALSE; - } - int curSelection = combo->GetSelection(); - + if (combo->m_prevSelection != curSelection) { GtkWidget *list = GTK_COMBO(combo->m_widget)->list; gtk_list_unselect_item( GTK_LIST(list), combo->m_prevSelection ); } - combo->m_prevSelection = curSelection; + if ((combo == gs_lastCombo) && + (combo->GetStringSelection() == gs_lastString)) + { + return; + } + else + { + gs_lastCombo = combo; + gs_lastString = combo->GetStringSelection(); + } + wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, combo->GetId() ); event.SetInt( curSelection ); event.SetString( combo->GetStringSelection() ); @@ -85,7 +80,7 @@ gtk_combo_select_child_callback( GtkList *WXUNUSED(list), GtkWidget *WXUNUSED(wi } //----------------------------------------------------------------------------- -// "changed" - typing and list item matches get changed, select-child, changed +// "changed" - typing and list item matches get changed, select-child // if it doesn't match an item then just get a single changed //----------------------------------------------------------------------------- @@ -96,15 +91,6 @@ gtk_text_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo ) if (!combo->m_hasVMT) return; - if ((combo->FindString(combo->GetValue()) != wxNOT_FOUND) && !combo->m_alreadySent) - { - gs_typedSelection = TRUE; - - // Do we send a TEXT_UPDATE event if we send a CMOBOBOX event - // anyways? I think so. - // return; - } - wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, combo->GetId() ); event.SetString( combo->GetValue() ); event.SetEventObject( combo ); @@ -405,6 +391,8 @@ int wxComboBox::FindString( const wxString &item ) #else wxString str( label->label ); #endif + wxPrintf( L"Item %s\n", str.c_str() ); + if (item == str) return count;