From: Vadim Zeitlin Date: Sun, 7 Oct 2012 22:42:50 +0000 (+0000) Subject: Ensure that key events are sent to focused window first in wxGTK. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/1bcef6701be81d1f4473eb5a297bdf20fa292d98 Ensure that key events are sent to focused window first in wxGTK. Start processing key events from the currently focused window, this ensures that its key event handlers are tried before the top level window accelerators. This is consistent with wxMSW and allows a window to locally override the global accelerators which really makes sense. Closes #14553. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72640 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/docs/changes.txt b/docs/changes.txt index af95c7bb2f..9a7e08d7e1 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -574,6 +574,7 @@ wxGTK: - Provide native implementation of wxNotificationMessage using libnotify. - Generate clipboard events for wxComboBox and not only wxTextCtrl. - Improve drag-and-drop of URLs. +- Make key event handling consistent with wxMSW (John Rails). wxMSW: diff --git a/src/gtk/toplevel.cpp b/src/gtk/toplevel.cpp index b561d5f61d..99119fa896 100644 --- a/src/gtk/toplevel.cpp +++ b/src/gtk/toplevel.cpp @@ -640,6 +640,14 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent, g_signal_connect_after (m_widget, "focus_out_event", G_CALLBACK (gtk_frame_focus_out_callback), this); + // GTK processes key events at the top level first, which handles for + // menu accelerators and shortcuts before passing the event on to the + // focus child window to begin propagation. We want to propagate + // first, so we connect gtk_window_propagate_key_event to + // key_press_event. + g_signal_connect (m_widget, "key_press_event", + G_CALLBACK (gtk_window_propagate_key_event), NULL); + #ifdef GDK_WINDOWING_X11 #ifdef __WXGTK3__ if (GDK_IS_X11_SCREEN(gtk_window_get_screen(GTK_WINDOW(m_widget))))