问题
I have an NSComboBox with a seperate class that conforms to NSComboBox dataSource and delegate.
If the user types text into the combo box that that does not match one of the items in the pop up list, how do I receieve a notification that the user has typed something in and also read the value that the user has typed?
At the moment I'm implimenting the delegate methods:-
-(void)comboBoxSelectionDidChange:(NSNotification *)notification
-(void)comboBoxWillDismiss:(NSNotification *)notification
However these appear only to be notified when the user has selected an item from the popup, not when the user types something else in stops editing
回答1:
Since NSComboBox
is a subclass of NSTextField
, and thus NSControl
, you can also use the NSControlTextEditingDelegate methods such as control:textShouldEndEditing: to affect the behavior of your combo box.
来源:https://stackoverflow.com/questions/6235122/nscombobox-how-to-tell-user-has-typed-in-information-that-is-not-in-the-pop-up