Color My Word--Open Color Palette
bornstein at designeq.com
Tue Apr 1 13:40:01 EST 2003
> I had discounted
>anything that required a locked field, since the user will be editing
>the field at the time. Then it hit me that all I needed was your field
>code and a little button to lock the field for them when they're ready
>to do the formatting.
Actually, you don't have to lock the field to get this stuff to work. I
used that in the example just to make it clear.
Let's say you have an unlocked text field that you want to allow a user
to format. Place some buttons next to it labeled "Bold", "Italic"
"Plain", etc. You can also provide popups for font and font size. Your
users simply selects any text that they want to operate on and click the
buttons or popups.
The basic code to operate on the selected text looks like this:
-- italicize the selected text
if the selection is not empty the
put the selectedchunk into sc
-- see if the text already has some style info
put the textstyle of sc into currentStyle
if currentStyle is empty then put "plain" into currentstyle
-- add italics to any existing style
put currentStyle&comma&"italic" into newStyle
set the textStyle of sc to newStyle
This will work fine, even if the text field is not locked.
Fonts and font sizes are a little different but not very hard. Let me
know if you want more details.
Hope this helps.
D E S I G N E Q
More information about the use-livecode