[Cuis] Newbie question

Dan Norton dnorton at mindspring.com
Thu Apr 2 19:24:26 CDT 2015


On 2 Apr 2015 at 16:53, Phil (list) wrote:

> On Thu, 2015-04-02 at 16:33 -0400, Dan Norton wrote:
[snip]
> > A simple solution is to have #name as an instance variable with 2
> supporting 
> > methods: #name: and #printOn: . When #name: 'foo' is OPTIONALLY
> sent, the 
> > name will appear  as "a BorderedRectMorph(1639)'foo'" when you
> middle click on 
> > the morph.
> > 
> 
> Rather than adding an ivar, why not just use a Morph property?
> (i.e.
> #setProperty:toValue: and #valueOfProperty:)
> 
+1

Morph>>printOn: could do the job with one line added:

printOn: aStream 

	super printOn: aStream.
	aStream nextPutAll: '('.
	aStream
		print: self identityHash;
		nextPutAll: ')'.
	self valueOfProperty: #morphName ifPresentDo: [:x | aStream nextPutAll: x asString]





More information about the Cuis mailing list