NSComboBox: How to tell user has typed in information that is not in the pop up list and read it

我与影子孤独终老i 提交于 2019-12-10 21:51:43

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!