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.
This commit is contained in:
Vadim Zeitlin
2018-10-27 15:06:42 +02:00
parent 9562ca2b70
commit 79a37a2a65
2 changed files with 8 additions and 5 deletions

View File

@@ -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()
*/

View File

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