Managing the hilite color of selected text

Pete pete at mollysrevenge.com
Tue Sep 27 20:11:14 EDT 2011


Thanks Terry, I pretty much have that logic in there now.  My remaining
problem is dealing with the tab key which I documented in another post on
this thread.

Is it just me or does seem like a lot of work to implement a pretty standard
user interface issue?  LC appears to remember the insertion point position
of a text field when you leave it so why not the selected text?

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




On Tue, Sep 27, 2011 at 4:17 PM, Terry Judd <tsj at unimelb.edu.au> wrote:

> Pete - try something like this in your field script
>
> local pSelection
>
> on mouseLeave
>   if word 2 of the selectedField = the number of me then
>      put the selectedChunk into pSelection
>   end if
> end mouseLeave
>
> on openField
>   if pSelection is not empty then
>      set the backgroundColor of pSelection to empty
>      put empty into pSelection
>   end if
> end openField
>
> on exitField
>   if pSelection is not empty then
>      set the backgroundColor of pSelection to "0,255,255"
>   end if
> end exitField
>
> on closeField
>   exitField
> end closeField
>
> Terry...
>
> On 28/09/2011, at 06:19 AM, Pete wrote:
>
> 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>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com<mailto:use-livecode at lists.runrev.com>
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>



More information about the use-livecode mailing list