different backgroundcolors in PluggableTextMorph?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

different backgroundcolors in PluggableTextMorph?

Wowerat Dirk
How can I set the backgroundcolor of substrings in PluggableTextMorphs?

In this short example, the word 'two' in red textcolor with yellow background.

currentPosition := 2.
myList := #('one' 'two' 'three' 'four' 'two').
myBlock := [:element |
    element = (myList at:currentPosition)
        ifTrue:[element asText addAttribute: (TextColor red);addAttribute: (TextEmphasis bold);addAttribute: (TextEmphasis italic)]
        ifFalse:[element asText addAttribute:(TextColor black)]
    ].
myText := myList inject:('' asText) into:[:txt :word| txt append: (myBlock value:word)].
myMorph := PluggableTextMorph new.
myMorph setText: myText.
myMorph openInHand.


I need this to mark some words in japanese text that is saved as list of words. (from mecab)

Dirk.