From f11270d478108c9ab0084a0da637dcb7edd1394c Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Sun, 2 Mar 2003 11:07:45 +0000 Subject: [PATCH] Do dialog's default action (mostly "OK") if ENTER was hit in a combobox and the TEXT_ENTER event was not handled. MSW seems to be doing something similar. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@19412 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/combobox.cpp | 19 ++++++++++++++++++- src/gtk1/combobox.cpp | 19 ++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/gtk/combobox.cpp b/src/gtk/combobox.cpp index 97cbfb477a..d719f40bc9 100644 --- a/src/gtk/combobox.cpp +++ b/src/gtk/combobox.cpp @@ -629,7 +629,24 @@ void wxComboBox::OnChar( wxKeyEvent &event ) event.SetString( GetValue() ); event.SetInt( GetSelection() ); event.SetEventObject( this ); - GetEventHandler()->ProcessEvent( event ); + + if (!GetEventHandler()->ProcessEvent( event )) + { + // 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 // down list upon RETURN. diff --git a/src/gtk1/combobox.cpp b/src/gtk1/combobox.cpp index 97cbfb477a..d719f40bc9 100644 --- a/src/gtk1/combobox.cpp +++ b/src/gtk1/combobox.cpp @@ -629,7 +629,24 @@ void wxComboBox::OnChar( wxKeyEvent &event ) event.SetString( GetValue() ); event.SetInt( GetSelection() ); event.SetEventObject( this ); - GetEventHandler()->ProcessEvent( event ); + + if (!GetEventHandler()->ProcessEvent( event )) + { + // 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 // down list upon RETURN.