From 99d7b13e3f221ed622143b5420afca244bf0007d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 9 Aug 2017 14:12:38 +0200 Subject: [PATCH] Force current item to stay visible in wxListCtrl after deletion The vertical scrollbar position could be updated (at least wit wxGTK) to not show the last item any longer, after deleting the previously last item, which was very annoying from the user point of view as the focus was visually lost. Avoid this by explicitly calling EnsureVisible() to prevent this from happening. --- src/generic/listctrl.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index 5c7bb48a71..d229958c0f 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -4092,6 +4092,12 @@ void wxListMainWindow::DeleteItem( long lindex ) m_dirty = true; RefreshAfter(index); + + // This might be a wxGTK bug, but when deleting the last item in a control + // with many items, the vertical scroll position may change so that the new + // last item is not visible any longer, which is very annoying from the + // user point of view. Ensure that whatever happens, this item is visible. + EnsureVisible(m_current); } void wxListMainWindow::DeleteColumn( int col )