When I assign a Menu to a button, the menu will be shown when the user right click the button.
I want to open the menu when the user left click the button.
Something similar to this:
I got it working using this code, However the menu is shown at the top right corner of my screen. What am I doing wrong?
@IBOutlet var meeenu: NSMenu!
@IBAction func Options(sender: NSButtonCell) {
meeenu.popUpMenuPositioningItem(meeenu.itemAtIndex(0), atLocation: NSEvent.mouseLocation(), inView: self.view)
}
I got it working finally using this code:
@IBOutlet var meeenu: NSMenu!
@IBAction func Options(sender: NSButtonCell) {
meeenu.popUpMenuPositioningItem(meeenu.itemAtIndex(0), atLocation: NSEvent.mouseLocation(), inView: nil)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With