]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/cocoa/combobox.mm
Fail in CloneGDIRefData() instead of implementing it incorrectly in wxOSX.
[wxWidgets.git] / src / osx / cocoa / combobox.mm
index 1666c33b83e687475b56dcee0521f3a6125fc618..4aec03feb346da7f83eb578eb356d7af165f4d98 100644 (file)
@@ -95,9 +95,21 @@ int wxNSComboBoxControl::GetSelectedItem() const
 
 void wxNSComboBoxControl::SetSelectedItem(int item)
 {
 
 void wxNSComboBoxControl::SetSelectedItem(int item)
 {
-    wxASSERT_MSG(item >= 0 && item < [m_comboBox numberOfItems], "Inavlid item index.");
     SendEvents(false);
     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);
 }
 
     SendEvents(true);
 }
 
@@ -132,9 +144,13 @@ wxString wxNSComboBoxControl::GetStringAtIndex(int pos) const
 
 int wxNSComboBoxControl::FindString(const wxString& text) const
 {
 
 int wxNSComboBoxControl::FindString(const wxString& text) const
 {
-    int result = [m_comboBox indexOfItemWithObjectValue:wxCFStringRef( text , m_wxPeer->GetFont().GetEncoding() ).AsNSString()];
-    if (result == NSNotFound)
+    NSInteger nsresult = [m_comboBox indexOfItemWithObjectValue:wxCFStringRef( text , m_wxPeer->GetFont().GetEncoding() ).AsNSString()];
+
+    int result;
+    if (nsresult == NSNotFound)
         result = wxNOT_FOUND;
         result = wxNOT_FOUND;
+    else
+        result = (int) nsresult;
     return result;
 }
 
     return result;
 }