Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to trigger button action on leftMouseDown in Swift, Mac OSX, Cocoa

I want to trigger a button on left mouse down in my mac osx app using swift.

This is the way to do it in Objective-C

[myButton sendActionOn:NSLeftMouseDownMask];

I can't figure out how to do it in Swift. Can anybody help me out with my problem?

Thanks!

like image 828
stefOCDP Avatar asked Oct 26 '25 11:10

stefOCDP


1 Answers

After a bit of fiddling in Xcode, this is what worked for me (Swift 2.0):

myButton.sendActionOn(Int(NSEventMask.LeftMouseDownMask.rawValue))
like image 81
Code Different Avatar answered Oct 28 '25 03:10

Code Different