Managed to get this one working.
- Added a variable for the die path:
var diePath: NSBezierPath?
-
Altered the draw code to update the variable in func drawDieWithSize()
self.diePath = NSBezierPath(roundedRect: dieFrame, xRadius: cornerRadius, yRadius: cornerRadius)
self.diePath!.fill() -
Changed the hit test to use the path
override func mouseDown(theEvent: NSEvent) {
Swift.print(“mouseDown”)
let pointInView = convertPoint(theEvent.locationInWindow, fromView: nil)
pressed = (self.diePath?.containsPoint(pointInView))!
}