From 55fb00a73ac36b896d91d2874468161c1ede19eb Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 7 Dec 2011 00:59:48 +0000 Subject: [PATCH] Pretend that the window showing popup menu has focus in wxGTK. This is necessary for compatibility with wxMSW as the focus remains on the window which had it before the popup menu was shown there and existing code relies on it, while in wxGTK the popup steals the focus when it's shown. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69938 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/window.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 9e62caa..74ba1ce 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -31,6 +31,7 @@ #include "wx/tooltip.h" #include "wx/caret.h" #include "wx/fontutil.h" +#include "wx/scopeguard.h" #include "wx/sysopt.h" #include @@ -4018,6 +4019,14 @@ bool wxWindowGTK::DoPopupMenu( wxMenu *menu, int x, int y ) { wxCHECK_MSG( m_widget != NULL, false, wxT("invalid window") ); + // For compatibility with other ports, pretend that the window showing the + // menu has focus while the menu is shown. This is needed because the popup + // menu actually steals the focus from the window it's associated it in + // wxGTK unlike, say, wxMSW. + wxWindowGTK* const oldPendingFocus = gs_pendingFocus; + gs_pendingFocus = this; + wxON_BLOCK_EXIT_SET( gs_pendingFocus, oldPendingFocus ); + menu->UpdateUI(); wxPoint pos; -- 2.7.4