How can I keep selected text hilited?

Mark Talluto userev at canelasoftware.com
Mon Mar 20 19:16:31 EST 2006


On Mar 20, 2006, at 1:43 PM   Mar 20, 2006, Robert E. Ball wrote:

> I want the user of my program to be able to hilite portions of a  
> text field on a given card (similar to using a yellow hilite pen on  
> a book page -- I have set hiliteColor to yellow) and then to have  
> the hilited text show up when the user returns to the card.
>
> When I first double click on a word in a field, the selected word's  
> backgroundColor turns yellow, as it should. However, when I double  
> click on another word in the field, the yellow backgroundColor of  
> the previously selected word is removed and the backgroundColor of  
> the second selected word is yellow. I understand why this works --  
> a new word has been selected. However, is it possible to write a  
> script to save the yellow backgroundColor of all selected words. In  
> other words, I would like my cards to look just like the page of a  
> book that has hilited text.

There probably is a few ways this can be done.  The first thing I  
would try is to store the selectedChunk information everytime there  
is a mouseUp.  You could store this in a variable or a custom property.

A quick and dirty solution would be the following:

on selectionChanged
     put the selectedChunk
     set the foreGroundColor of the selectedChunk to 255,0,0
end selectionChanged



More information about the Use-livecode mailing list