当我将菜单分配给按钮时,当用户右键单击该按钮时,将显示菜单.
我想在用户左键单击按钮时打开菜单.
与此类似的东西:
我使用此代码工作,但菜单显示在我的屏幕的右上角.我究竟做错了什么?
@IBOutlet var meeenu: NSMenu!
@IBAction func Options(sender: NSButtonCell) {
meeenu.popUpMenuPositioningItem(meeenu.itemAtIndex(0), atLocation: NSEvent.mouseLocation(), inView: self.view)
}
Run Code Online (Sandbox Code Playgroud)
Fai*_*sal 11
我终于使用这段代码了解它:
@IBOutlet var meeenu: NSMenu!
@IBAction func Options(sender: NSButtonCell) {
meeenu.popUpMenuPositioningItem(meeenu.itemAtIndex(0), atLocation: NSEvent.mouseLocation(), inView: nil)
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1837 次 |
| 最近记录: |