如何获取当前选择的NSPopUpButtonCell? [英] How to retrieve the current selection of an NSPopUpButtonCell?
问题描述
我在 NSTableView
中使用 NSPopUpButtonCell
。弹出按钮绑定到 ApplicationDelegate
提供的 NSArray
属性。当我选择弹出按钮的菜单项时,我希望检索当前选择或其索引。我添加了一个IBAction被通知,并设置了 NSMenuDelegate
。 两者都始终返回index = 0。
I am using an NSPopUpButtonCell
in an NSTableView
. The popup button has a binding to an NSArray
property offered by the ApplicationDelegate
. When I select a menu item of the popup button I expect to retrieve the current selection or its index. I added an IBAction to being informed and also set up an NSMenuDelegate
. Both return index = 0 at all times.
// indexOfSelectedItem is always 0.
NSInteger indexOfSelectedItem = [m_popUpButtonCell indexOfSelectedItem];
我创建了一个示例项目。希望您能澄清一些事情。
I created an example project with the aforementioned configuration. Hopefully you can clarify things.
推荐答案
本文使用弹出式菜单实现一对一关系回答了我的问题。
我更新了示例项目。
The article Implementing To-One Relationships Using Pop-Up Menus answered my question.
I updated the example project.
这篇关于如何获取当前选择的NSPopUpButtonCell?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!