让 NSComboBox 像 HTML Combo 一样工作

发布于 2024-08-14 03:10:24 字数 149 浏览 2 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甜心 2024-08-21 03:10:24

您在寻找 NSPopUpButton 吗?它更类似于 HTML

无论如何,您应该能够为任一控件提供一组具有 recordid 属性的自定义对象,然后使用 [[comboBox objectValueOfSelectedItem] recordid] 检索选择。您还需要为这些对象编写自定义格式化程序。

Are you looking for NSPopUpButton? It's more similar to an HTML <select>. An NSComboBox 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.

暮色兮凉城 2024-08-21 03:10:24

弹出按钮就是它。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文