From 2ac90f9d38737a6d275309ed443d8870c89f69e0 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 9 Jul 2020 19:55:03 +0200 Subject: [PATCH] Don't call SetFocus() for popups not using wxPU_CONTAINS_CONTROLS Under MSW only popup windows with wxPU_CONTAINS_CONTROLS can have focus, attempting to set it to a [child of a] popup without it will just result in a debug error message from wxWindow::SetFocus() and nothing else, so just avoid doing it entirely. --- src/msw/popupwin.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/msw/popupwin.cpp b/src/msw/popupwin.cpp index 0c42cd5aa9..10900fa61f 100644 --- a/src/msw/popupwin.cpp +++ b/src/msw/popupwin.cpp @@ -180,10 +180,10 @@ void wxPopupTransientWindow::Popup(wxWindow* focus) { Show(); - // 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) ) + // We can only set focus when using wxPU_CONTAINS_CONTROLS and then only to + // one of our children as setting it to another window would result in an + // immediate loss of activation and popup disappearance. + if ( HasFlag(wxPU_CONTAINS_CONTROLS) && focus && IsDescendant(focus) ) focus->SetFocus(); }