[squeak-dev] TextMorph minimal width

St├ęphane Rollandin lecteur at zogotounga.net
Mon Aug 8 20:41:28 UTC 2022


In 6.0

	(TextMorph new contents: 'B';
		backgroundColor: Color green)

yields a Morph that is wider than needed by an extra character

changing #minCompositionWidth in TextMorph by removing the * 2 fixes 
that problem, but introduces another one (bad layout of modal window 
titles) that can itself be fixed by reintroducing the same * 2 in 
#minWidth as follow:


	| result |
	result := self minCompositionWidth * 2 + (self borderWidth*2).
	margins ifNil: [^ result].
	^ margins isRectangle
		ifTrue: [result + margins left + margins right]
		ifFalse: [margins isPoint
			ifTrue: [result + margins x + margins x]
			ifFalse: [result + (2*margins)]]

Is that correct?


More information about the Squeak-dev mailing list