让 NSComboBox 像 HTML Combo 一样工作
NSComboBox 中显示的值是否可能与使用 objectValueOfSelectedItem 检索到的值不同?
那么,它会显示一个对象的字符串名称,但返回的是 int recordId 而不是字符串名称?当然,除了使用选定的索引并从源数组中获取它之外......
Is it possible to have the values displayed in an NSComboBox be different from what is retrieved with objectValueOfSelectedItem?
So, it will display an object's string name but it's int recordId is returned instead of the string name? Other than using selected index and getting it from the source array, of course...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您在寻找
NSPopUpButton
吗?它更类似于 HTML无论如何,您应该能够为任一控件提供一组具有
recordid
属性的自定义对象,然后使用[[comboBox objectValueOfSelectedItem] recordid]
检索选择。您还需要为这些对象编写自定义格式化程序。Are you looking for
NSPopUpButton
? It's more similar to an HTML<select>
. AnNSComboBox
lets users directly type in new values, as well as pick them from a list, but you can't do that with plain HTML.In any event, you should be able to give either control a bunch of custom objects that have a
recordid
property, and then retrieve the selection using[[comboBox objectValueOfSelectedItem] recordid]
. You'll also need to write a custom formatter for these objects.弹出按钮就是它。
objectValueOfSelectedItem 对我不起作用,因为它返回显示的内容,并且我想要显示字符串但返回 int 。
PopupButton is it.
objectValueOfSelectedItem wont work for me since it returns what is displayed and I want a string displayed but int returned.