Strange behavior using Text and TextMorph
Ned Konz
ned at squeakland.org
Thu Feb 26 21:56:43 UTC 2004
On Thursday 26 February 2004 11:42 am, Alexandre Bergel wrote:
> Screen capture by Ken
> http://www.kencausey.com/colortext.gif
>
>
> And by me:
> http://www.iam.unibe.ch/~bergel/text.tiff
>
> I use a mac laptop with Jaguar. I have tried different VM with different
> image, and I still have the same result. I cannot change a color of a text.
>
> If anyone has an idea about this strange behavior...
>
> Cheers,
> Alexandre
It's easy...
((Text fromString: 'this is a test') addAttribute: TextColor green) asMorph
openInHand
The problem is that asMorph is defined (in String) as:
String>>asMorph
"Answer the receiver as a StringMorph"
^ StringMorph contents: self
So in a stock image this is equivalent to:
(StringMorph contents: ((Text fromString: 'this is a test') addAttribute:
TextColor green)) openInHand
And StringMorph ignores everything in a Text except the emphasis
(bold/italic/etc.) at the first character.
Perhaps it would make sense to also grab the color.
Really, you want to define
Text>>asMorph
^ TextMorph new contents: self
I notice that Brent has done this in some version of the BFAV; I think this is
a useful change by itself.
I just posted a CS that fixes this.
--
Ned Konz
http://bike-nomad.com/squeak/
More information about the Squeak-dev
mailing list
|