Set the color of a sigle word in a field

Ken Ray kray at sonsothunder.com
Mon Mar 14 01:16:17 EST 2005


On 3/13/05 11:30 PM, "Kevin J" <kj2005.28 at gmail.com> wrote:

> Ok I was trying every thing that I could think of to get this to work.
> I was reading all the docs to see if I could figure it out but its not
> working. What I am trying to do is when someone types in the word
> "while" into the field"txtWindow" it will set that word to the color
> blue but all the other words will stay black. I can't figure it out
> for the life of me. Is there something that I can download to look at
> that as somthing almost the same?

Kevin,

Here you go - fully tested and genericized so you can do other words as
well. This also works if they move the insertion point somehere else in the
field and type "while". Put this in the field:   (watch for line breaks)

on rawKeyUp
  put "while" into tBlueWord
  put length(tBlueWord)-1 into tLen
  put word 4 of the selectedChunk into tCharNum
  if char (tCharNum-tLen) to tCharNum of me is tBlueWord then
    set the textColor of char (tCharNum-tLen) to tCharNum of me to blue
  else
    set the textColor of char tCharNum of me to black
  end if
end rawKeyUp

HTH,


Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com





More information about the Use-livecode mailing list