- if ( m_cb->GetCount() == 0 )
- {
- // make Enter generate "selected" event if there is only one item
- // in the combobox - without it, it's impossible to select it at
- // all!
- wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, m_cb->GetId() );
- event.SetInt( 0 );
- event.SetString( value );
- event.SetEventObject( m_cb );
- m_cb->GetEventHandler()->ProcessEvent( event );
- }
- else
- {
- // add the item to the list if it's not there yet
- if ( m_cb->FindString(value) == wxNOT_FOUND )
- {
- m_cb->Append(value);
- m_cb->SetStringSelection(value);
-
- // and generate the selected event for it
- wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, m_cb->GetId() );
- event.SetInt( m_cb->GetCount() - 1 );
- event.SetString( value );
- event.SetEventObject( m_cb );
- m_cb->GetEventHandler()->ProcessEvent( event );
- }
+ // send the event to the combobox class in case the user has bound EVT_CHAR
+ wxKeyEvent kevt(event);
+ kevt.SetEventObject(m_cb);
+ if (m_cb->GetEventHandler()->ProcessEvent(kevt))
+ // If the event was handled and not skipped then we're done
+ return;
+
+ if ( event.GetKeyCode() == WXK_RETURN )
+ {
+ wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_cb->GetId());
+ event.SetString( GetValue() );
+ event.SetInt( m_cb->GetSelection() );
+ event.SetEventObject( m_cb );