property NSColor : class "NSColor"
property NSBezierPath : class "NSBezierPath"
property NSString : class "NSString"
script DotView
property parent : class "NSView"
property |center| : {x:0.0, y:0.0}
property radius : 0.0
property |color| : missing value
property enablePoof : false
on initWithFrame:frame
continue initWithFrame:frame
set my |center|'s x to 50.0
set my |center|'s y to 50.0
set my radius to 10.0
set my |color| to NSColor's redColor()
return me
end initWithFrame:
on drawRect:rect
NSColor's whiteColor()'s |set|()
tell ((NSBezierPath's bezierPathWithRect:(my |bounds|()))) to fill()
set origin to {(my |center|'s x) - (my radius), (my |center|'s y) - (my radius)}
set |size| to {2 * (my radius), 2 * (my radius)}
my |color|'s |set|()
tell ((NSBezierPath's bezierPathWithOvalInRect:{origin, |size|})) to fill()
end drawRect:
on isOpaque()
return true
end isOpaque
on mouseUp:|event|
set eventLocation to |event|'s locationInWindow()
set my |center| to my convertPoint:eventLocation fromView:(missing value)
tell me to setNeedsDisplay:true
end mouseUp:
on setRadius:sender
set radius to sender's doubleValue()
tell me to setNeedsDisplay:true
end setRadius:
on setColor:sender
set my |color| to sender's |color|()
tell me to setNeedsDisplay:true
end setColor:
end script