April 2015
Intermediate to advanced
556 pages
17h 47m
English
To get mouse events, you need to override the mouse event methods. Open DieView.swift from Chapter 17 and override the methods in DieView:
// MARK: - Mouse Events
override func mouseDown(theEvent: NSEvent) {
println("mouseDown")
}
override func mouseDragged(theEvent: NSEvent) {
println("mouseDragged location: \(theEvent.locationInWindow)")
}
override func mouseUp(theEvent: NSEvent) {
println("mouseUp clickCount: \(theEvent.clickCount)")
}
Build and run your application. Try double-clicking, and check the click count. Note that the first click is sent and then the second click. The first click has a click count of 1; the second click has a click count of 2.
Read now
Unlock full access