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.
This commit is contained in:
Vadim Zeitlin 2020-07-09 19:55:03 +02:00
parent 03e79fce63
commit 2ac90f9d38

View File

@ -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();
}