Morphs embedded in text

Karl Ramberg karl.ramberg at chello.se
Sun Aug 26 16:57:42 UTC 2001


Joerg Beekmann wrote:
> 
> 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:

> BUT then substituting a TextMorph for a PluggableTextMorph as below does not work. I get a window only showing the
> TextFieldMorph. Any ideas?
> 
Both examples work for me( in a 3.1-42xx image). 
The second one shows up as white 
text on black background in a very
wide window. From my experiments I found that 
TextMorphs were picky and could screw up layout totally
Another issue is in this method that gets called from
TextMorph>>contentsWrapped:


TextMorph>>newContents: stringOrText 
	"Accept new text contents."
	| newText embeddedMorphs |
	newText _ stringOrText copy asText.	"should be veryDeepCopy?"
	text = newText ifTrue: [^ self].	"No substantive change"
	text ifNotNil: [(embeddedMorphs _ text embeddedMorphs)
			ifNotNil: 
				[self removeAllMorphsIn: embeddedMorphs.
				embeddedMorphs do: [:m | m delete]]].

	text _ newText.

	"add all morphs off the visible region; they'll be moved into the right 
	place when they become visible. (this can make the scrollable area too 
	large, though)"
	newText embeddedMorphs do: 
		[:m | 
		self addMorph: m.
		m position: -1000 @ 0].
	self releaseParagraph.
	"update the paragraph cache"
	self paragraph.
	"re-instantiate to set bounds"
	self world ifNotNil: [self world startSteppingSubmorphsOf: self]

I don't really understand why submorphs get stripped out of the text and
added back in at -1000 at 0 ?
I comented out that part of the code and got more reliable results:

TextMorph>>newContentsWithEmbeddedMorphs: stringOrText 
	"Accept new text contents."
	| newText |
	newText _ stringOrText copy asText.	"should be veryDeepCopy?"
	wrapFlag _ false.
	container ifNotNil: [container fillsOwner ifTrue: [wrapFlag _ true]].
	text = newText ifTrue: [^ self].	"No substantive change"
	text _ newText.
	self releaseParagraph.
	"update the paragraph cache"
	self paragraph.
	"re-instantiate to set bounds"
	self world ifNotNil: [self world startSteppingSubmorphsOf: self]


Karl




More information about the Squeak-dev mailing list