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.
This commit is contained in:
Vadim Zeitlin
2018-12-15 23:44:01 +01:00
parent abc4576ffe
commit c8d2195791

View File

@@ -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<unsigned>(sel) >= n )
{
SetSelection(wxNOT_FOUND);
}
}
m_items.RemoveAt(n);
m_HTMLclientData.RemoveAt(n);