]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/cocoa/combobox.mm
Remove unnecessary wxOSX_USE_COCOA guards in Cocoa-only file.
[wxWidgets.git] / src / osx / cocoa / combobox.mm
index 1666c33b83e687475b56dcee0521f3a6125fc618..d98f0a331e526f52a279d3c0b81d0e8f47da66d4 100644 (file)
@@ -95,9 +95,21 @@ int wxNSComboBoxControl::GetSelectedItem() const
 
 void wxNSComboBoxControl::SetSelectedItem(int item)
 {
-    wxASSERT_MSG(item >= 0 && item < [m_comboBox numberOfItems], "Inavlid item index.");
     SendEvents(false);
-    [m_comboBox selectItemAtIndex: item];
+
+    if ( item != wxNOT_FOUND )
+    {
+        wxASSERT_MSG( item >= 0 && item < [m_comboBox numberOfItems],
+                      "Inavlid item index." );
+        [m_comboBox selectItemAtIndex: item];
+    }
+    else // remove current selection (if we have any)
+    {
+        const int sel = GetSelectedItem();
+        if ( sel != wxNOT_FOUND )
+            [m_comboBox deselectItemAtIndex:sel];
+    }
+
     SendEvents(true);
 }