[英]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. 我想使用swift在我的mac osx应用程序中触发鼠标左键。
This is the way to do it in Objective-C 这是在Objective-C中实现它的方法
[myButton sendActionOn:NSLeftMouseDownMask];
I can't figure out how to do it in Swift. 我无法弄清楚如何在Swift中做到这一点。 Can anybody help me out with my problem? 有人可以帮我解决我的问题吗?
Thanks! 谢谢!
在Xcode中稍微摆弄之后,这对我有用(Swift 2.0):
myButton.sendActionOn(Int(NSEventMask.LeftMouseDownMask.rawValue))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.