text color
Mike Bonner
bonnmike at gmail.com
Tue Nov 22 12:43:15 EST 2011
Last time. I swear. Really. Would help if I'd locate all the quirks before
posting, eh?
The problem with the last code is that if nothing is found it still hilites
from the beginning of the field for the number of chars in the search
string. So to fix that..
on mouseUp
set the wholematches to true
put field "results" into field "results"
set the traversalOn of field "Results" to true
put the text of field Results into tResults
put the text of field "SearchField" into strSearch
put the length of strSearch into tLength
put 1 into tFramePos
put 0 into tPreviousOffset
repeat while tFramePos <> 0
put Offset(strSearch,tResults,tPreviousOffset) into tFramePos
if tFramePos <> 0 then -- check to see if there is a match THEN do
the color change
select char (tFramePos + tPreviousOffset) to (tFramePos +
tPreviousOffset + tLength - 1) of field "results"
set the textColor of the selection to red
put tFramePos + tPreviousOffset into tPreviousOffset
end if -- ta da! 12th time is the charm.
end repeat
select empty
end mouseUp
More information about the use-livecode
mailing list