Morphs embedded in text

Karl Ramberg karl.ramberg at chello.se
Sun Aug 26 05:55:10 UTC 2001


Joerg Beekmann wrote:
> 
> Is there a way to embed morphs into text so they behave as part of the text during resizing? The effect I'm after is
> demonstrated by the entry field in the HTML at the end of this message. I've tried various table layouts without
> success. The problem I'm having is that the layout considers each morph added as a cell and then arranges those cells.
> But what I want to do is have a morph be treated as a character in the text.
> 
> Joerg
> 
> <html>
>         <body>
> 
>                 This is a bunch of text in the body of my document.
>                 The text contains an embedded entry field that behaves like part of the text.
>                 <input type="text" value="the initial contents">
>                 This is some text following the entry field.
> </html>

This is exactly what I am trying to figure out how to do in 
table support for Scamper. 
The solution is TextAnchors, but I don't know how to use them yet...
Look at 
TextMorph>>addMorphFront: aMorph fromWorldPosition: wp 
	"Overridden for more specific re-layout and positioning"
	| i |
	self addMorphFront: aMorph.
	i _ (self paragraph characterBlockAtPoint: (self transformFromWorld
globalPointToLocal: wp))
		stringIndex.
	self paragraph replaceFrom: i to: i-1
		with: (Text string: '*' attribute: (TextAnchor new anchoredMorph: aMorph))
		displaying: false.
	self fit

This method is used for drag and drop I guess because it 
refers to world position. 
The HtmlFormatter produces a text looking like this:'  * * * '
where each asterisk is a text anchor, but when I initializes
a TextMorph with this as string it will loose the anchor
info. The anchor info is stored in a additional collection 
in the formatter. 

Hope this helps. If you figure it out, let me know.
I will report any progress I make to the list :-)

Karl




More information about the Squeak-dev mailing list