如何制作带有图像和文本菜单的NSPopupButton?

Mic*_*hop 2 cocoa binding nspopupbuttoncell nspopupbutton

我有一个应用程序列表,我想制作一个NSPopupButton应用程序名称菜单,每个项目左侧有一个图标.

我已经能够绑定NSPopupButton到我的项目数组,但没有图像的绑定条目.我以为我可以把一个细胞放在那里并将细胞绑定为图像和文本,但我在IB中找不到合适的细胞.

有没有一种干净简单的方法来使用绑定?我必须写一个自定义单元格吗?

Pet*_*sey 6

使用库存NSPopUpButton无法绑定图像以及菜单项的标题.您必须将其子类化并编写IBPlugin以公开子类.当然,你也应该处理细胞.

I've found mixing Bindings with NSPopUpButton to be a bag of hurt for a variety of reasons, including the impossibility of separators and of out-of-model menu items such as "Default" or "All". Consider using a different control, such as a source list, or populating and re-populating the pop-up menu manually.