X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ce4ae5639b5c1cd9aa45ed766d0f5abae029ca2f..5e382463783f520fbbc4272dd777c9da0ce4f08a:/src/common/bookctrl.cpp diff --git a/src/common/bookctrl.cpp b/src/common/bookctrl.cpp index 9ec08bad1c..8d86c5343e 100644 --- a/src/common/bookctrl.cpp +++ b/src/common/bookctrl.cpp @@ -456,6 +456,26 @@ bool wxBookCtrlBase::DoSetSelectionAfterInsertion(size_t n, bool bSelect) return true; } +void wxBookCtrlBase::DoSetSelectionAfterRemoval(size_t n) +{ + if ( m_selection >= (int)n ) + { + // ensure that the selection is valid + int sel; + if ( GetPageCount() == 0 ) + sel = wxNOT_FOUND; + else + sel = m_selection ? m_selection - 1 : 0; + + // if deleting current page we shouldn't try to hide it + m_selection = m_selection == (int)n ? wxNOT_FOUND + : m_selection - 1; + + if ( sel != wxNOT_FOUND && sel != m_selection ) + SetSelection(sel); + } +} + int wxBookCtrlBase::DoSetSelection(size_t n, int flags) { wxCHECK_MSG( n < GetPageCount(), wxNOT_FOUND,