From c8d2195791a752bfd046f1a9042b08ccf5340bce Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 15 Dec 2018 23:44:01 +0100 Subject: [PATCH] Make wxSimpleHtmlListBox::Delete() consistent with wxListBox Also remove the selection when deleting the selected item, or any item before it, in this class, for consistency with the native wxListBox. --- src/generic/htmllbox.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/generic/htmllbox.cpp b/src/generic/htmllbox.cpp index 507badf53b..cc7ef82ac1 100644 --- a/src/generic/htmllbox.cpp +++ b/src/generic/htmllbox.cpp @@ -672,6 +672,18 @@ void wxSimpleHtmlListBox::Clear() void wxSimpleHtmlListBox::DoDeleteOneItem(unsigned int n) { + // For consistency with the other wxItemContainer-derived classes, deselect + // the currently selected item if it, or any item before it, is being + // deleted, from a single-selection control. + if ( !HasMultipleSelection() ) + { + const int sel = GetSelection(); + if ( sel != wxNOT_FOUND && static_cast(sel) >= n ) + { + SetSelection(wxNOT_FOUND); + } + } + m_items.RemoveAt(n); m_HTMLclientData.RemoveAt(n);