+ if ( event.KeyCode() == WXK_RETURN )
+ {
+ wxString value = GetValue();
+
+ if ( Number() == 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, GetId() );
+ event.SetInt( 0 );
+ event.SetString( value );
+ event.SetEventObject( this );
+ GetEventHandler()->ProcessEvent( event );
+ }
+ else
+ {
+ // add the item to the list if it's not there yet
+ if ( FindString(value) == wxNOT_FOUND )
+ {
+ Append(value);
+ SetStringSelection(value);
+
+ // and generate the selected event for it
+ wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, GetId() );
+ event.SetInt( Number() - 1 );
+ event.SetString( value );
+ event.SetEventObject( this );
+ GetEventHandler()->ProcessEvent( event );
+ }
+ //else: do nothing, this will open the listbox
+ }
+ }
+
+ event.Skip();