Morphs embedded in text
Joerg Beekmann
jbeekmann at attglobal.net
Sun Aug 26 07:07:03 UTC 2001
Karl; thanks for the tip. I've played with TextAnchors a bit and by running with the class comment for TextAnchor the
following seems to get me close to what I (you?) want:
morphAsText := Text
string: '*'
attribute: (TextAnchor new anchoredMorph: (TextFieldMorph new contents: 'data here'; yourself)).
text := (TextStream on: Text new)
nextPutAll: 'This is the text before a morph: ';
nextPutAll: morphAsText;
nextPutAll: ' here is some text following the morph.';
contents.
(PluggableTextMorph on: nil text: nil accept: nil)
setText: text;
openInWindow
BUT then substituting a TextMorph for a PluggableTextMorph as below does not work. I get a window only showing the
TextFieldMorph. Any ideas?
morphAsText := Text string: '*'
attribute: (TextAnchor new anchoredMorph: (TextFieldMorph new contents: 'data here'; yourself)).
text := (TextStream on: Text new)
nextPutAll: 'This is the text before a morph: ';
nextPutAll: morphAsText;
nextPutAll: ' here is some text following the morph.';
contents.
(TextMorph new)
contentsWrapped: text;
openInWindow
-----Original Message-----
From: squeak-dev-admin at lists.squeakfoundation.org
[mailto:squeak-dev-admin at lists.squeakfoundation.org]On Behalf Of Karl
Ramberg
Sent: August 25, 2001 10:55 PM
To: squeak-dev at lists.squeakfoundation.org
Subject: Re: Morphs embedded in text
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
|