cod*_*ody 9 cocoa objective-c nsmenu nsmenuitem nspopupbutton
我正在为应用程序编写一个插件 - 自定义键盘快捷键.我可以遍历其观点.我需要打开弹出菜单,选择其中的项目,然后打开其子菜单并在子菜单中选择一些项目.
现在我只能通过发送performClick:到相关NSPopUpButton元素来打开顶部弹出菜单.
如何以编程方式选择菜单中的项目并打开其子菜单?
我试过了:
使用该NSMenu方法- (void)performActionForItemAtIndex:(NSInteger)index
NSUInteger idx = [[[menuItem menu] itemArray] indexOfObject:menuItem];
[[menuItem menu] performActionForItemAtIndex:idx];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3445 次 |
| 最近记录: |