I am wondering how I can get this function to work, I just don't understand how to get correct type for NSEvent or where I even find it using developer documentation.
func mouseDown(with event: NSEvent)
I am trying to make an IF Statement that prints "User has clicked mouse" within a console window.
I am not looking for you to solve this problem for me, I am just hoping that you can show me a way that I can solve this for myself using developer documentation, please don't just link me a copy paste thread from another stack overflow unless it teaches me how people are finding the information required to solve these problems.
I just don't understand what goes inside of the parameter (with event: NSEvent) or how you would even find this out without just copying someone else's work.
All you need is to override your view controller func mouseDown(with event: NSEvent)
method. Just make sure you dont change the method signature and include the override keyword and dont forget to call super.
import Cocoa
class ViewController: NSViewController {
// ...
override func mouseDown(with event: NSEvent) {
super.mouseDown(with: event)
print(#function)
}
override func rightMouseDown(with event: NSEvent) {
super.rightMouseDown(with: event)
print(#function)
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.