How to retrieve the current selection of an NSPopUpButtonCell?

拥有回忆 提交于 2019-12-13 02:08:31

问题


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.


回答1:


The article Implementing To-One Relationships Using Pop-Up Menus answered my question.
I updated the example project.



来源:https://stackoverflow.com/questions/9033872/how-to-retrieve-the-current-selection-of-an-nspopupbuttoncell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!