Page 1 of 1
BlendLevel
Posted: Wed Oct 21, 2009 8:07 pm
by mtecedor
Hi All,
I am trying to do something I dont even know if its possible.
Does anyone know if it is possible to change the blendLevel of the background color?
I have a field users can hilite in two colors or delete the hiliting. The problem is that is a chunk of text is hilited, it is impossible to se the autohilite behind the background color, so it is difficult to tell what words you are selecting exactly.
Thanks
Marta
Posted: Wed Oct 21, 2009 8:45 pm
by bn
Marta,
couldnt you just use the foregroundcolor instead of the backgroundcolor? Another name for the foregroundcolor is textcolor. The foregroundcolor changes the color of the characters instead of having a color behind the black characters. This way you can see the autohilite and the text quite well.
regards
Bernd
Posted: Wed Oct 21, 2009 9:55 pm
by mwieder
Changing the hilitecolor would be another way to tackle this.
Posted: Wed Oct 21, 2009 11:33 pm
by mtecedor
Changing the foreground color is not an option, I really need it to have a hiliting effect.
I also tried changing the autohilite color, but it seems that the background is on top of the hilite, thats why I wanted to try changing the blendLevel of the backgroundColor.
Posted: Thu Oct 22, 2009 12:05 pm
by bn
Marta,
here is a piece of code that lets you hilite your text in green while hiliting and then setting the backgroundcolor of the selected text to yellow.
I am not quite shure if it is what you want.
It would help a lot if you would give as a little context of how this is going to be used by your users. What are they doing in the text and what does the hiliting tell you.
try this, it is based on a piece of code you found helpful, look at the comments in the code or ask if anything is not clear or does not work as you like it
Code: Select all
local hiliteCounter, hilitedList, tGreen
on mouseDown
put true into tGreen --start the mouseMove handler
end mouseDown
on mouseMove
if tGreen then
set the backgroundcolor of the selectedChunk to green
end if
end mouseMove
on mouseUp
put false into tGreen -- stop the mouseMove handler
if the optionkey is down then -- resets all if Alt-Key or Option-Key is down
set the backgroundcolor of char 1 to -1 of me to ""
set the foregroundcolor of char 1 to -1 of me to ""
put 0 into hiliteCounter
put "" into hilitedList
put "" into field "output"
exit mouseUp
end if
put hiliteCounter+1 into hiliteCounter
put word 2 of the selectedChunk into tStartChar
put word 4of the selectedChunk into tEndChar
-- if the user clicks before the first word it selects the whole text
if tEndChar = 0 then exit mouseUp
put "1234567890.,¿!abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'-" into tTestString
-- take the text of field "text2" into a variable tTest to speed things up
put field "text2" into tTest
put false into tFoundStart
repeat until tFoundStart = true
put char tStartChar of tTest into tChar
if tChar is not in tTestString then
put true into tFoundStart
else
subtract 1 from tStartChar
end if
end repeat
put false into tFoundEnd
repeat until tFoundEnd = true
put char tEndChar of tTest into tChar
if tChar is not in tTestString then
put true into tFoundEnd
else
add 1 to tEndChar
end if
end repeat
set backgroundcolor of char tStartChar+1 to tEndChar-1 of field "Text2" to yellow
put char tStartChar+1 to tEndChar-1 of tTest into tReplaceReturns
-- take returns out so it won't break the lines of the hilitedList
replace return with "|" in tReplaceReturns
put tStartChar+1 & " " & tReplaceReturns into line hiliteCounter of hilitedList
sort hilitedList numeric
-- put hilitedList into field 3
-- we leave the hilitedList alone and work on a copy of it
put hilitedList into tListToClean
repeat with i = 1 to the number of lines of tListToClean
delete word 1 of line i of tListToClean
end repeat
-- remove empty lines
filter tListToClean without empty
-- put the returns back in
replace "|" with return in tListToClean
-----
-- here we recolor the selected text to yellow backgroundcolor
-- because if user selects forward and backwards in one move
-- there would be green selection remnants
lock screen
set the backgroundcolor of char 1 to -1 of field "text2" to ""
repeat for each line aLine in hilitedList
put the length of word 1 of aLIne into tIndexLength
put the length of aLine into tLineLength
if tIndexLength = tLineLength then next repeat
set backgroundcolor of char (word 1 of aLine) to (word 1 of aLine + tLineLength - tIndexLength -2) of field "text2" to "yellow"
end repeat
unlock screen
-- end of recolorisation
------
put tListToClean into field "output"
select after char tEndChar of me -- to avoid stray selectioncolor remnants
end mouseUp
regards
Bernd