Managing the hilite color of selected text

Pete pete at mollysrevenge.com
Tue Sep 27 16:19:38 EDT 2011


LC does not retain the hilite of any selected text in a field once you click
on another control and does not restore it when you click back into the
field again.  I'm hoping to find a generalised solution to this.

In other applications, it seems that the standard way of working is:

- change the hilite of any selected text in a field to a light grey color
when another control is clicked

- change the hilite back to the blue hilite color if the user tabs back into
the field

- clear the hilite completely if the user clicks back into the field

That's the behavior I'm aiming for.

So far, I have:

- a mouseLeave handler that sets a custom property of the field to its
selectedChunk  and changes the backgroundcolor of the selectedchunk to gray

- a mouseEnter handler that uses the custom property to set the
backgroundcolor of the selected text back to blue again.

So far so good.  What remains is to handle what happens when the user
arrives back into the field either by tabbing into it or by clicking into
it.

So far I have tried to use an openField handler to achieve this.  Right now,
I'm just trying to deal with the situation where the user clicks back into
the field, by setting the background color of the field to either empty or
white, but neither method removes the highlight from the selected text and
if I type more text into the field, it appears with the hilite background
color.  Even if I delete all the text in the field and type new text in, it
still appears with the blue background color.

The other issue is how to distinguish between the user clicking into the
field and tabbing into it.

I'm pretty sure this must have come up before so hoping for some guidance
from anyone who has come up with the solution.

Thanks,



Pete
Molly's Revenge <http://www.mollysrevenge.com>



More information about the use-livecode mailing list