From 711b548c59aecf83a433be515ab2bb48a673a763 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Wed, 22 Sep 2021 19:37:08 +0200 Subject: [PATCH] Invalidate selection of item being removed from wxChoice (wxOSX) We need to explicitly invalidate selection of item being removed because it's not done by wxChoiceWidgetsImpl::RemoveItem(). --- src/osx/choice_osx.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/osx/choice_osx.cpp b/src/osx/choice_osx.cpp index fac0ccb173..df52d2cbd2 100644 --- a/src/osx/choice_osx.cpp +++ b/src/osx/choice_osx.cpp @@ -146,6 +146,11 @@ void wxChoice::DoDeleteOneItem(unsigned int n) if ( HasClientObjectData() ) delete GetClientObject( n ); + // Deselect item being removed + int selIdx = GetSelection(); + if ( selIdx != -1 && selIdx == n ) + SetSelection(-1); + dynamic_cast(GetPeer())->RemoveItem(n); m_strings.RemoveAt( n ) ; m_datas.RemoveAt( n ) ;