From 2f3fc152bf0cc67d89bfd92c29b8b9efb369b6a7 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Mon, 20 Sep 2021 22:00:23 +0200 Subject: [PATCH] Invalidate selection of item being removed from wxNSComboBoxControl We need to explicitly invalidate selection of item being removed because it's not done by NSComboBox (selection index is retained). --- src/osx/cocoa/combobox.mm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/osx/cocoa/combobox.mm b/src/osx/cocoa/combobox.mm index 5b8ffd938d..b3899405c6 100644 --- a/src/osx/cocoa/combobox.mm +++ b/src/osx/cocoa/combobox.mm @@ -294,6 +294,14 @@ void wxNSComboBoxControl::InsertItem(int pos, const wxString& item) void wxNSComboBoxControl::RemoveItem(int pos) { SendEvents(false); + + // Explicitly deselect item being removed + int selIdx = [m_comboBox indexOfSelectedItem]; + if (selIdx!= -1 && selIdx == pos) + { + [m_comboBox deselectItemAtIndex:selIdx]; + } + [m_comboBox removeItemAtIndex:pos]; SendEvents(true); }