/////////////////////////////////////////////////////////////////////////////
-// Name: combobox.cpp
+// Name: src/gtk/combobox.cpp
// Purpose:
// Author: Robert Roebling
// Id: $Id$
{
// when the popup is hidden, throw a SELECTED event only if the combobox
// selection changed.
- int curSelection = combo->GetCurrentSelection();
- if (g_SelectionBeforePopup != curSelection)
+ const int curSelection = combo->GetCurrentSelection();
+
+ const bool hasChanged = curSelection != g_SelectionBeforePopup;
+
+ // reset the selection flag to value meaning that it is hidden and do it
+ // now, before generating the events, so that GetSelection() returns the
+ // new value from the event handler
+ g_SelectionBeforePopup = wxID_NONE;
+
+ if ( hasChanged )
{
wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, combo->GetId() );
event.SetInt( curSelection );
event.SetString( combo->GetStringSelection() );
event.SetEventObject( combo );
combo->GetEventHandler()->ProcessEvent( event );
- }
- // reset the selection flag to value meaning that it is hidden
- g_SelectionBeforePopup = wxID_NONE;
+ // for consistency with the other ports, send TEXT event
+ wxCommandEvent event2( wxEVT_COMMAND_TEXT_UPDATED, combo->GetId() );
+ event2.SetString( combo->GetStringSelection() );
+ event2.SetEventObject( combo );
+ combo->GetEventHandler()->ProcessEvent( event2 );
+ }
}
}
event.SetEventObject( combo );
combo->GetEventHandler()->ProcessEvent( event );
- // for consistencu with the other ports, don't generate text update
+ // for consistency with the other ports, don't generate text update
// events while the user is browsing the combobox neither
wxCommandEvent event2( wxEVT_COMMAND_TEXT_UPDATED, combo->GetId() );
event2.SetString( combo->GetValue() );
// Disable GTK's broken events ...
gtk_signal_disconnect( GTK_OBJECT(combo->entry), combo->entry_change_id );
- // ... and add surogate handler.
+ // ... and add surrogate handler.
combo->entry_change_id = gtk_signal_connect (GTK_OBJECT (combo->entry), "changed",
(GtkSignalFunc) gtk_dummy_callback, combo);
InvalidateBestSize();
}
-int wxComboBox::FindString( const wxString &item ) const
+int wxComboBox::FindString( const wxString &item, bool bCase ) const
{
wxCHECK_MSG( m_widget != NULL, wxNOT_FOUND, wxT("invalid combobox") );
#else
wxString str( label->label );
#endif
- if (item == str)
+ if (item.IsSameAs( str , bCase ) )
return count;
count++;
if ( event.GetKeyCode() == WXK_RETURN )
{
// GTK automatically selects an item if its in the list
- wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, GetId());
- event.SetString( GetValue() );
- event.SetInt( GetSelection() );
- event.SetEventObject( this );
+ wxCommandEvent eventEnter(wxEVT_COMMAND_TEXT_ENTER, GetId());
+ eventEnter.SetString( GetValue() );
+ eventEnter.SetInt( GetSelection() );
+ eventEnter.SetEventObject( this );
- if (!GetEventHandler()->ProcessEvent( event ))
+ if (!GetEventHandler()->ProcessEvent( eventEnter ))
{
// This will invoke the dialog default action, such
// as the clicking the default button.