cocoa - 如何在 NSTokenField 中传递indexofselecteditem

标签 cocoa nstokenfield

我从 tokenField:completionsForSubstring:indexOfToken:indexOfSelectedItem 获得的返回破坏了我输入的项目。这解释了为什么: 阅读本文NSTokenField does not let me type other strings than tokenField:completionsForSubstring:… returns回答了我的大部分问题。

在回答时,Jim Correia 说:“因此,如果列表中没有表示子字符串,则您需要将其设置为 -1(否则它将用您第一次完成的文本替换用户输入的文本) ...”在我的例子中,规范是返回 -1 但我不知道如何做到这一点?也许我只是在某个地方错过了它?

谢谢!

最佳答案

重读文档,我终于完成了它。将此添加到 tokenField:completionsForSubstring:indexOfToken:indexOfSelectedItem::

*selectedIndex = -1;

我错过了“按引用返回”位。

关于cocoa - 如何在 NSTokenField 中传递indexofselecteditem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9381741/

相关文章:

macos - 在 NSTokenField 中删除一个 token

objective-c - NSTokenField 指定的初始值设定项是什么?

cocoa - Mail.app 类似 NSTokenField 用于姓名和电子邮件

objective-c - 如何选择要在我的 Cocoa 应用程序中使用的网络接口(interface)

objective-c - 仅适用于我的应用程序的私有(private) cookie?为什么它会影响浏览器的 cookie?

ios - 有没有办法在编辑 UITableView 时隐藏 "-"(删除)按钮

objective-c - 具有混合 token /字符串输入的 NSTokenField,可能吗?

cocoa - Xcode-使 Textview 永远水平继续

objective-c - 给出我的程序 'options'