April 2015
Intermediate to advanced
556 pages
17h 47m
English
When a view has the focus (which just means that it is the first responder), its appearance changes. For text input controls this is generally indicated with a blue ring around the control. For table views, the selection highlight may change from gray to blue.
Cocoa makes it very easy to draw the focus ring.
Simply implement this method and property. Add them to the
// MARK: - First Responder section.
override func drawFocusRingMask() {
NSBezierPath.fillRect(bounds)
}
override var focusRingMaskBounds: NSRect {
return bounds
}
Now your users can see which die they will be changing. Note that drawFocusRingMask() allows you to draw any path. You could easily make the focus ring take the shape of the die’s rounded rectangle. ...