TextMorph "Actual" bounds

Ned Konz ned at bike-nomad.com
Mon Feb 25 17:07:09 UTC 2002


On Monday 25 February 2002 03:31 am, Jim Rosenberg wrote:
> If I apply the bounds method to a TextMorph, the rectangle I get may or may
> not reflect the "actual" size of the text "as drawn".  E.g. if every line
> of the text has "hard" line-breaks, the morph may have been resized via the
> halo to a size much bigger than the minimum necessary to actually draw the
> text.
>
> I need to find the bounds of the actual text as drawn, regardless of the
> current size of the morph.  What's the easiest way to do this?

Something like this should work (I think):

myTextMorph paragraph adjustRightX; extent

If you're just looking for the "natural" size of the text (that is, with only 
hard line breaks), you can do this:

(Paragraph withText: myTextMorph text) boundingBox 

but that doesn't get the size "as drawn".

-- 
Ned Konz
currently: Stanwood, WA
email:     ned at bike-nomad.com
homepage:  http://bike-nomad.com



More information about the Squeak-dev mailing list