Ensure that the currently shown wxSimplebook page has focus

When calling wxSimplebook::ChangeSelection(), the focus remained on the
previous, now hidden, page, unless it was explicitly set to one of the
controls on the new page.

This was completely unexpected as it could result in the user
(inadvertently) changing the values of the already "accepted" controls
on the last page, so don't let this happen and always set the focus to
the new page explicitly, even if this hasn't been done by
ShowWithEffect() which doesn't do it at least under wxMSW.

See #23914.

(cherry picked from commit 7e9d06f58436300243fe3b8b076dc222b63dea2e)
This commit is contained in:
Vadim Zeitlin 2023-09-28 20:58:25 +02:00
parent c0519934aa
commit a0794ca229
2 changed files with 9 additions and 0 deletions

View File

@ -276,6 +276,7 @@ All (GUI):
- Fix wxFileHistory formatting after calling Load() (Hartwig Wiesmann, #23799).
- Fix wxRichTextCtrl layout in high DPI (mbc-one, Maarten Bent, #23828).
- Ensure current cell stays valid when wxGrid table changes (CookieLau, #23751).
- Always give focus to the currently shown wxSimplebook page (#23914).
wxGTK:

View File

@ -215,9 +215,17 @@ protected:
virtual void DoShowPage(wxWindow* page, bool show) wxOVERRIDE
{
if ( show )
{
page->ShowWithEffect(m_showEffect, m_showTimeout);
// Unlike simple Show(), ShowWithEffect() doesn't necessarily give
// focus to the window, but we do expect the new page to have focus.
page->SetFocus();
}
else
{
page->HideWithEffect(m_hideEffect, m_hideTimeout);
}
}
private: