From d6ddcd574bce0167851aef142be1f9722c694654 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 25 Jul 2001 16:13:32 +0000 Subject: [PATCH] fix for focus handling when deleting the items git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11175 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/generic/listctrl.h | 1 - src/generic/listctrl.cpp | 12 +++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/include/wx/generic/listctrl.h b/include/wx/generic/listctrl.h index 2b633a5a0e..75cab160e5 100644 --- a/include/wx/generic/listctrl.h +++ b/include/wx/generic/listctrl.h @@ -196,7 +196,6 @@ protected: virtual wxListItemAttr *OnGetItemAttr(long item) const; // it calls our OnGetXXX() functions - friend class WXDLLEXPORT wxListMainWindow; private: diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index 23f67b2520..5aeb20c2e5 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -3813,10 +3813,16 @@ void wxListMainWindow::DeleteItem( long lindex ) size_t index = (size_t)lindex; - // select the next item when the selected one is deleted - if ( m_current >= index ) + // we don't need to adjust the index for the previous items + if ( HasCurrent() && m_current >= index ) { - m_current--; + // if the current item is being deleted, we want the next one to + // become selected - unless there is no next one - so don't adjust + // m_current in this case + if ( m_current != index || m_current == count - 1 ) + { + m_current--; + } } if ( InReportView() ) -- 2.45.2