0

I have a NSComboBox with a lot of items. Therefore I activated auto completion, so that the user can "search" for the item, he needs.

In addition I have a button, which the user have to click, after the item is selected. This button is disabled and should only be enabled, if a item of the combobox is selected.

Getting the selection by click is easy, there I only need the IBAction.
But how can I know, when the combobox completes the entered text?

I want to enable the button as soon as the auto completion found an item.

cacau
  • 3,606
  • 3
  • 21
  • 42
Lupurus
  • 3,618
  • 2
  • 29
  • 59

1 Answers1

0

Ok, I found the solution by myself.

At first I tried to look in the controlTextDidChange method, if the indexOfSelectedItem >= 0. This works, but not perfect.

This works fine:

override func controlTextDidChange(obj: NSNotification!) {
    if obj.object as NSObject == myComboBox {
        myButton.enabled = myComboBox.indexOfItemWithObjectValue(myComboBox.stringValue) != NSNotFound
    }
}
Lupurus
  • 3,618
  • 2
  • 29
  • 59