From 79a37a2a65d8bde315bcd863838f21c72912840a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 27 Oct 2018 15:06:42 +0200 Subject: [PATCH] Don't try to set focus outside of popup window in wxMSW This will just hide the window immediately, so prefer to ignore the "focus" argument of Popup() but show the popup instead. Update the documentation to mention that setting focus outside of popup is not supported under all platforms. --- interface/wx/popupwin.h | 8 ++++---- src/msw/popupwin.cpp | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/interface/wx/popupwin.h b/interface/wx/popupwin.h index fb1030b171..01af6cfa63 100644 --- a/interface/wx/popupwin.h +++ b/interface/wx/popupwin.h @@ -84,10 +84,10 @@ public: /** Popup the window (this will show it too). - If @a winFocus is non-@NULL, it will be kept focused while this window - is shown, otherwise this window itself will receive focus. In any case, - the popup will disappear automatically if it loses focus because of a - user action. + If @a focus is non-@NULL, it will be kept focused while this window + is shown if supported by the current platform, otherwise the popup + itself will receive focus. In any case, the popup will disappear + automatically if it loses focus because of a user action. @see Dismiss() */ diff --git a/src/msw/popupwin.cpp b/src/msw/popupwin.cpp index eea9c444bc..406733d73d 100644 --- a/src/msw/popupwin.cpp +++ b/src/msw/popupwin.cpp @@ -96,7 +96,10 @@ void wxPopupTransientWindow::Popup(wxWindow* focus) { Show(); - if ( focus ) + // We can only set focus to one of our children as setting it to another + // window would result in an immediate loss of activation and popup + // disappearance. + if ( focus && IsDescendant(focus) ) focus->SetFocus(); }