NSPopUpButton + Bindings +显示所有选项 [英] NSPopUpButton + Bindings + Show All Option

查看:546
本文介绍了NSPopUpButton + Bindings +显示所有选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想开发一个 NSPopUpButton ,作为一个数据源的过滤器,让我们说一个 NSArrayController

I'm trying to develop a NSPopUpButton that will serve as a filter to some datasource, let's say a NSArrayController that fills a table.

我可以将 NSArrayController 从菜单绑定到选择键,因此数据是正确过滤,没有问题。

I can bind the NSArrayController from the menu to the selection keypath so the data is properly filtered, no problem with that.

Tricky部分是,我想要 NSPopUpButton 的内容一个 NSArrayController 使用绑定,但我想添加一个显示所有菜单项,或至少一些不是来自Core Data并执行一些

Tricky part is, I want the content of this NSPopUpButton to rely on an NSArrayController using bindings, but I'd like to add a "Show All" menu item, or at least some item that doesn't come from the Core Data and performs some special action other than filtering the table using bindings and core data.

我尝试执行类似于 NSPopUpButton finder在过滤栏中使用,菜单的最后一个项执行一个特殊的操作,而其他人只是过滤结果。

I'm trying to perform something like the NSPopUpButton used by finder in the filter bar, the last item of the menu performs a special action, while the others just filter the result.

我理解,方法是忘记绑定,并以编程方式做这一切,因为我相信没有办法搞砸与 NSArrayController 和绑定添加这个自定义菜单项,不依赖于核心数据,但是因为我没有在苹果文档和在这里找到任何东西,我想分享我的想法...任何想法?

I understand that the approach is to forget about bindings and do it everything programmatically, because I believe there's no way to mess up with the NSArrayController and bindings to add this custom menu item that doesn't rely on core data, but since I haven't found anything on the Apple Docs and here, I'd like to share my thoughts... any ideas?

推荐答案

听起来像是你正在寻找NSContentPlacementTagBindingOption。

sounds to me like you're looking for the NSContentPlacementTagBindingOption.

你编辑附加到NSPopupButton的NSMenu如下

you edit the NSMenu that's attached to the NSPopupButton as follows

然后编辑要替换为数组控制器内容的NSMenuItem上的设置,使其具有与其相关联的有意义的标记

you then edit the settings on the NSMenuItem you want to have replaced with your array controller contents so that it has a meaningful tag associated with it

,然后在NSPopupButton对content / content *绑定的绑定上指定该标记作为内容放置标记值。

you then specify that tag as the content placement tag value on the NSPopupButton's bindings for the content/content* bindings.

这篇关于NSPopUpButton + Bindings +显示所有选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆