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

标签 objective-c macos cocoa-bindings

我有一个 NSComboBox,它有一个符合 NSComboBox 数据源和委托(delegate)的独立类。

如果用户在组合框中键入的文本与弹出列表中的一项不匹配,我如何收到用户已键入内容的通知并读取用户键入的值?

目前我正在实现委托(delegate)方法:-

-(void)comboBoxSelectionDidChange:(NSNotification *)notification 
-(void)comboBoxWillDismiss:(NSNotification *)notification 

然而,这些似乎只有在用户从弹出窗口中选择了一个项目时才会收到通知,而不是在用户在停止编辑中键入其他内容时收到通知

最佳答案

由于 NSComboBoxNSTextField 的子类,因此 NSControl 也可以使用 NSControlTextEditingDelegate methods例如control:textShouldEndEditing:影响组合框的行为。

关于objective-c - NSComboBox : How to tell user has typed in information that is not in the pop up list and read it,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6235122/

相关文章:

ios - 自动生成的 CoreML 类使用了冲突的初始值设定项

ios - 在 IOS 应用程序中验证

xcode - 在 xcode 中制作 .saver 文件而不使用屏幕保护程序类型项目

objective-c - NSPopUpButton + 绑定(bind) + 显示所有选项

ios - UIViewController 与 NSViewController

macos - 以编程方式将 NSTreeController 绑定(bind)到 NSOutlineView

objective-c - 使用 NSFetchedResultsController 将谓词从核心数据模型提取到各个部分中

ios - MOTIS 对象映射,使用 NSDictionary 和值 NSArray 如何指定数组元素的类型?

java - CodeNameOne 设计器堆设置在哪里?

objective-c - NSBox 没有显示在其中添加内容的方法(Swift)