text color script
FMoyer at aol.com
FMoyer at aol.com
Sun May 4 12:58:00 EDT 2003
I want the user to be able to change at will the color of text in the fields
of a stack I am designing. To do this, I've made a group that contains three
buttons: a black button, a red button and a blue button. If the user presses
one of the colored buttons while text is selected, that selectedtext becomes
red or blue or black. And if the user clicks in a field, what he types next
will automatically be the color of the button that is hilited.
The script works -- it is below. But it seems to be a clumsy solution.
Basically, each time the user types in a field, my script changes that
character to the correct color. I am worried that it might be creating some
junk in the fields that is messing up the stack. The stack has been acting
strangely (i.e., crashing.) Could you look at the script below and tell me if
there is not a better simpler way to accomplish my task? Thanks.
Incidentally, I'm using Mac OS 9.2.2 and MC2.5.
Fred Moyer
Explanation: The group of buttons is called "textColorButtons" -- in it are 3
radio buttons - their names are "black", "red", "blue."
**The script for group "textColorButtons"
on mouseUp
global globalselectedchunk,selectedColorButton
if word 4 of GlobalSelectedchunk + 1 <> word 2 of GlobalSelectedchunk and
GlobalSelectedchunk is not empty then
--- This is to change the color of text that is highlighted
do "set the textcolor of " & globalselectedchunk & " to " & (the short
name of the target)
set the hilite of btn id selectedColorButton to true
do "select " & globalselectedchunk
else
set the hilite of btn (the short name of the target) to true
if GlobalSelectedchunk is not empty then
do "select " & globalselectedchunk
end if
end if
end mouseUp
on mouseenter
global globalselectedchunk,selectedColorButton
put the selectedchunk into GlobalSelectedchunk
put the hilitedbuttonId of group "textColorButtons" into selectedColorButton
end mouseenter
**The script for the group that contains the fields:
on keydown what
if the selectedtext is not empty then pass keydown
put the selectedchunk into sc
put what after char (word 4 of sc) of fld (last word of sc)
set the textcolor of char (word 4 of sc) + 1 of fld (last word of sc) to
(the hilitedbuttonName of group "textcolorbuttons")
select char (word 4 of sc) + 2 to (word 4 of sc) + 1 of fld (last word of
sc)
end keydown
More information about the metacard
mailing list