AlignmentMorph and TextMorph

Bob Arning arning at charm.net
Sun Dec 27 21:05:23 UTC 1998


On Sun, 27 Dec 1998 11:44:46 -0500 "Pennell's" <pennell at tiac.net> wrote: 

>
>The names are all left justified (expected), the scores are all 
>right justified. (why?)

Andrew's explanation probably answers this one. Incidentally, if the scores are 1000, 100, 10, and 1, then the 1 does not appear right-justified in your example since there is (see TextMorph>>fit) a minimum size for TextMorphs. Using #contentsWrapped: instead of #contents: and adding #rightFlush will correct this.


>The names are editable, the scores are not.  (why?)
>

Well, they are editable in my system, but then I dug around a bit and found I had "fixed" this problem before. TextMorphs seem to think they have an unlimited width and thus the first one on the line will answer true to #containsPoint: and the second one never sees it. My change is:

TextMorph>>containsPoint:

containsPoint: aPoint
	
	(super containsPoint: aPoint) ifFalse: [^false].
	self startingIndex > text size ifTrue:
		["make null text frame visible"
		^ super containsPoint: aPoint].
	^ self paragraph containsPoint: aPoint


With this change, both will be editable. If you change your morph creation methods to send #lock to the name and score morphs, then neither is editable. As in:

scoreMorph: score

	^TextMorph new 
		contentsWrapped: score printString; rightFlush; lock

Cheers,
Bob





More information about the Squeak-dev mailing list