[MCP] [Q] Color change notification

Bill Spight bspight at pacbell.net
Tue Mar 18 16:35:55 UTC 2003


Dear Ned,

> Of course, in Morph all changed does is invalidate the rectangle. It's 
> not the same as Object>>changed (i.e. it's not a change 
> notification).
> 

Then why in the world should Morph>>color: invalidate the rectangle?????

How about this? Change Morph>>color: to

color: aColor
	"Change the receiver's color.  Directly set the color if appropriate,
else go by way of fillStyle. Notify of color change. (To set the color
initially, use #defaultColor.)"

	(aColor isColor or: [aColor isKindOf: InfiniteForm]) ifFalse:[^ self
fillStyle: aColor].
	color = aColor ifFalse:
		[self removeProperty: #fillStyle.
		color _ aColor.
		self colorChanged]
                     ^^^^^^^^^^^^
(Note also changes to comment.)

Calling the new method "colorChanged" is consistent with other usage,
such as "layoutChanged". 

Best regards,

Bill



More information about the Squeak-dev mailing list