Colouring words

dunbarx at aol.com dunbarx at aol.com
Mon Aug 10 09:51:59 EDT 2015


@Mark


There is nothing wrong with setting the textColor of an entire line. Any valid chunk expression would do.


@, Richmond:


What are you seeing? Why does it not work? I am in v 6.7.


Craig Newman






-----Original Message-----
From: Richmond <richmondmathewson at gmail.com>
To: How to use LiveCode <use-livecode at lists.runrev.com>
Sent: Mon, Aug 10, 2015 8:58 am
Subject: Re: Colouring words


On 10/08/15 14:45, Mark Schonewille wrote:
> Hi Richmond,
>
> It may not be
as easy as you think:
>
> repeat with x = 1 to number of words of line y of
fld "What"
>   if word x of line y of fld "What" is "only" then
>     set the
textColor of word x of line y of fld "What" to red
>   end if
> end
repeat
>
> or
>
> put the htmlText of fld "What" into myText
> replace
"only" with "<font color=" & quote & \
>   "red" & quote & ">only</font" in
myText
> set the htmlText of fld "What" to myText
>
> Both approaches have
advantages and disadvantages.
>
> -- 
> Best regards,
>
> Mark
Schonewille
>
>

<snip>

> On 8/10/2015 13:39, Richmond wrote:
>> what is
wrong with this:
>>
>> if line 5 of fld "WHAT" contains "only" then
>>       
set the textColor of "only" in line 5 of fld "WHAT" to red
>>           end
if
>>
>> ???
>>
>> I would like to set certain phrases in a sentence to a
different
>> textColor to the other words . . .
>>
>> . . . should be dead
easy.
>>
>> Richmond.

Oh, well . . .

I was well aware I could do
this:

on mouseUp
    set the textColor of word 3 of line 1 of fld "WHAT" to
red
end mouseUp


it just seemed incredibly longwinded to have to write
stuff like this:

on mouseUp
    if word 3 of line 1 of fld "WHAT" is "only"
then
    set the textColor of word 3 of line 1 of fld "WHAT" to red
    end
if
end mouseUp

and then, as you have suggested, write a routine to trawl
through all 
the words in a
line.

Richmond.

_______________________________________________
use-livecode
mailing list
use-livecode at lists.runrev.com
Please visit this url to subscribe,
unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

 



More information about the use-livecode mailing list