From d9c8932188eae4c4bc0c223deaa3ee38c88f20c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C4=83t=C4=83lin=20R=C4=83ceanu?= Date: Wed, 20 Feb 2019 19:12:48 +0200 Subject: [PATCH] Ensure a valid page is initially selected in the widgets sample Select first page if an invalid one was restored which may happen if the build of the library has changed (e.g. some previously disabled wxUSE_XXX became enabled etc). Closes https://github.com/wxWidgets/wxWidgets/pull/1235 --- samples/widgets/widgets.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/widgets/widgets.cpp b/samples/widgets/widgets.cpp index c2e44da45f..0d26fc05e8 100644 --- a/samples/widgets/widgets.cpp +++ b/samples/widgets/widgets.cpp @@ -639,7 +639,7 @@ void WidgetsFrame::InitBook() #if USE_TREEBOOK // for treebook page #0 is empty parent page only so select the first page // with some contents - if ( !pageSet ) + if ( !pageSet || !m_book->GetCurrentPage() ) m_book->SetSelection(1); // but ensure that the top of the tree is shown nevertheless @@ -648,7 +648,7 @@ void WidgetsFrame::InitBook() wxTreeItemIdValue cookie; tree->EnsureVisible(tree->GetFirstChild(tree->GetRootItem(), cookie)); #else - if ( !pageSet ) + if ( !pageSet || !m_book->GetCurrentPage() ) { // for other books set selection twice to force connected event handler // to force lazy creation of initial visible content