如何在 Swift、Mac OSX、Cocoa 中触发 leftMouseDown 按钮操作

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

我想在我的 mac osx 应用程序中使用 swift 触发鼠标左键按下按钮。

这是Objective-C

中的方法
[myButton sendActionOn:NSLeftMouseDownMask];

我在 Swift 中不知道该怎么做。有人可以帮我解决我的问题吗?

谢谢!

在 Xcode 中进行了一些调整后,这对我有用 (Swift 2.0):

myButton.sendActionOn(Int(NSEventMask.LeftMouseDownMask.rawValue))