From 7e9d06f58436300243fe3b8b076dc222b63dea2e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 28 Sep 2023 20:58:25 +0200 Subject: [PATCH] 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. Closes #23914. --- include/wx/simplebook.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/wx/simplebook.h b/include/wx/simplebook.h index e4c754f8f6..fa122a82a3 100644 --- a/include/wx/simplebook.h +++ b/include/wx/simplebook.h @@ -195,9 +195,17 @@ protected: virtual void DoShowPage(wxWindow* page, bool show) override { 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: