only generate wxEVT_COMMAND_TEXT_ENTER if the combobox has wxTE_PROCESS_ENTER style (for compatibility with wxMSW and wxTextCtrl); removed code using gtk_widget_activate() as this shouldn't be needed here at all

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49624 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-11-04 16:16:46 +00:00
parent dff6cf576a
commit 643c973bd8

View File

@@ -780,7 +780,10 @@ void wxComboBox::SetSelection( int n )
void wxComboBox::OnChar( wxKeyEvent &event ) void wxComboBox::OnChar( wxKeyEvent &event )
{ {
if ( event.GetKeyCode() == WXK_RETURN ) switch ( event.GetKeyCode() )
{
case WXK_RETURN:
if ( HasFlag(wxTE_PROCESS_ENTER) )
{ {
// GTK automatically selects an item if its in the list // GTK automatically selects an item if its in the list
wxCommandEvent eventEnter(wxEVT_COMMAND_TEXT_ENTER, GetId()); wxCommandEvent eventEnter(wxEVT_COMMAND_TEXT_ENTER, GetId());
@@ -788,28 +791,15 @@ void wxComboBox::OnChar( wxKeyEvent &event )
eventEnter.SetInt( GetSelection() ); eventEnter.SetInt( GetSelection() );
eventEnter.SetEventObject( this ); eventEnter.SetEventObject( this );
if (!GetEventHandler()->ProcessEvent( eventEnter )) if ( GetEventHandler()->ProcessEvent(eventEnter) )
{ {
// This will invoke the dialog default action, such
// as the clicking the default button.
wxWindow *top_frame = m_parent;
while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
top_frame = top_frame->GetParent();
if (top_frame && GTK_IS_WINDOW(top_frame->m_widget))
{
GtkWindow *window = GTK_WINDOW(top_frame->m_widget);
if (window->default_widget)
gtk_widget_activate (window->default_widget);
}
}
// Catch GTK event so that GTK doesn't open the drop // Catch GTK event so that GTK doesn't open the drop
// down list upon RETURN. // down list upon RETURN.
return; return;
} }
}
break;
}
event.Skip(); event.Skip();
} }