Click to Roll
Your users have been clamoring for a way to roll the die. The designer thinks that double-clicking on it would be a sensible way to accomplish this, so let’s add it. Add a randomize() method to DieView:
func randomize() { intValue = Int(arc4random_uniform(5)) + 1 }
In mouseUp(_:), use NSEvent’s clickCount to check for the double-click before calling randomize():
override func mouseUp(theEvent: NSEvent) { println("mouseUp clickCount: \(theEvent.clickCount)") if theEvent.clickCount ...
Get Cocoa Programming for OS X: The Big Nerd Ranch Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.