Displaying colored text

Jon Hylands Jon at huv.com
Wed Jul 26 16:34:43 UTC 2000


On Wed, 26 Jul 2000 18:05:03 +0200, Thomas Kuehne
<kuehne at informatik.uni-kl.de> wrote:

> I tried my luck with a ListComponent morph, but although the emphasis (normal/bold/italic) was respected the colors did not come through.
> Any quick hint how to display a list of differently coloured text lines?

If you do it by code, its easy. Just create a TextMorph, set its
contents to the string you want to display, and ask for its Text
object (asText).

Then, for each color you want:
	- create a TextColor object with the appropriate color
	- send #addAttribute:from:to: to the Text object, with the
	  TextColor and the range in the string you want the color
	  applied to

When you're done, send openInWorld to the text morph, and you'll see
your text in colors.

You can also do it by inspecting a text morph that is already opened,
and sending the messages to it from inside the inspector. If you do
that, you need to send #changed to the morph to make it redisplay in
color.

Later,
Jon

--------------------------------------------------------------
   Jon Hylands      Jon at huv.com      http://www.huv.com/jon

  Project: Micro Seeker (Micro Autonomous Underwater Vehicle)
           http://www.huv.com





More information about the Squeak-dev mailing list