Q: Updating TextMorph when embedded morph change size?

Karl Ramberg karl.ramberg at chello.se
Sun Mar 10 20:16:49 UTC 2002


Hannes Hirzel wrote:
> 
> On Sat, 9 Mar 2002, Karl Ramberg wrote:
> 
> > I'm doing some layout stuff and need to update the paragraph
> > because the size of embedded submorphs change. Anybody got a tip
> > on how to make the TextMorph do this automagically ?
> >
> > Karl
> >
> >
> 
> I updated the bullet list morph I posted recently. It is on
> http://minnow.cc.gatech.edu/squeak/2141
> 
> Resizing with the yellow halo works now the way I like it to have.
> 
> The crucial point for the TextMorph is to do the following:
> 
> t := TextMorph new.
> t layoutPolicy: TableLayout new.
> t hResizing: #spaceFill.  "I want the text to expand to the whole
>                            width of the enclosing Morph"
> t vResizing: #shrinkWrap. "I do want to have the text enclosed as tight as
>                            possible in the vertical direction"
> 
> However some trial and error was necessary and I had to add
> as the two last lines
> 
> item1 layoutChanged.
> item2 layoutChanged.
> 
> just after I open the enclosing RectangleMorph.
> 
> It would be great if a Morphic specialist could look into this and
> give some advice how to streamline the code.
> 
> To summarize: The short answer is to send
> layoutChanged to either the TextMorph or the enclosing Morph and to
> have set up the properties of the TextMorph in the correct way, of
> which I'm not yet sure what would be the canonical form.
> 
> Please keep me updated if you find out something additional.

I tested the code but it does not help, because I resize the embedded
morph 
within the text. You can test by creating a TextMorph and turn on
accepts drops
and drop a morph on the text, then resize the dropped morph with the
yellow handle.
Seems like textmorph must be told to look at it's submorphs and whether
any of them 
has changed.

Karl



More information about the Squeak-dev mailing list