Avoid events when implicitly selecting first wxBookCtrl page.

The first page added to a wxBookCtrlBase-derived control is always selected,
even if "bSelect" argument of AddPage() was false. This is necessary because
a non-empty book control must always have a selection but the "selection
changed" event generated when doing it is unexpected.

Fix this by not generating any events when the first page is implicitly
selected.

Closes #12075.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65967 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2010-10-31 13:33:34 +00:00
parent 03263ff73b
commit 60d5c563d2
7 changed files with 29 additions and 57 deletions

View File

@@ -471,6 +471,19 @@ int wxBookCtrlBase::GetNextPage(bool forward) const
return nPage;
}
bool wxBookCtrlBase::DoSetSelectionAfterInsertion(size_t n, bool bSelect)
{
if ( bSelect )
SetSelection(n);
else if ( m_selection == wxNOT_FOUND )
ChangeSelection(0);
else // We're not going to select this page.
return false;
// Return true to indicate that we selected this page.
return true;
}
int wxBookCtrlBase::DoSetSelection(size_t n, int flags)
{
wxCHECK_MSG( n < GetPageCount(), wxNOT_FOUND,