+ if ( event.GetKeyCode() == WXK_RETURN )
+ {
+ wxString value = GetValue();
+
+ 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 );
+ }
+
+ // This will invoke the dialog default action, such
+ // as the clicking the default button.
+
+ wxWindow *parent = GetParent();
+ while( parent && !parent->IsTopLevel() && parent->GetDefaultItem() == NULL ) {
+ parent = parent->GetParent() ;
+ }
+ if ( parent && parent->GetDefaultItem() )
+ {
+ wxButton *def = wxDynamicCast(parent->GetDefaultItem(),
+ wxButton);
+ if ( def && def->IsEnabled() )
+ {
+ wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() );
+ event.SetEventObject(def);
+ def->Command(event);
+ return ;
+ }
+ }
+
+ return;
+ }
+ }