Add wxBookCtrlBase::DoSetSelectionAfterRemoval() and use it in wxSimplebook.
This fixes the wrong handling of the selection in wxSimplebook when the currently selected page was deleted. Also extend the unit tests to check for this bug. Closes #15188. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74279 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user