I've got a NSStatusBar item I'm drawing an (variable depending on user settings) image onto. After the image is set, I draw a simple rectangle/bezierpath over the image to indicate a sort of progress. The progress/rect seems like it isn't updating, but when I change the color of the fill, you can see that it draws that properly, but the "progress rect" with the original color still exists behind it. Here is what I've got:
button.image = nil // resetting this seems like it would also clear it out?
var img : NSImage
let perc = Int(cPerc)
if round == true {
img = NSImage(named: "round")!
} else {
img = NSImage(named: "square")!
}
button.image = img
let frame = CGRect(x: 0, y: 0, width: 25, height: 15) // main button icon frame
drawInnerRect(frame: frame, cperc: self.curPerc, attr: atr) // draw the inside bezierpath
button.needsDisplay = true // should update the drawing???
...
func drawInnerRect(frame frame: NSRect, cperc : NSNumber, attr: NSDictionary)
{
let fillColor = attr.valueForKey("fill") as! NSColor
statusItem.button!.image?.lockFocus()
let per = ((cperc.doubleValue / 100.0) * 17.0)
let rectanglePath = NSBezierPath(rect: NSMakeRect(frame.minX+2, frame.minY+2, CGFloat(per), 8))
NSColor.clearColor().set() // trying to use this *should* reset the rect fill??
rectanglePath.fill()
fillColor.setFill()
rectanglePath.fill()
statusItem.button!.image?.unlockFocus()
}
This is my first post on here, be gentle...