Thanks Mike & Richmond.

Mike – your solution provides the behaviour I'm after but does seem to live on 
the edge of a runaway loop!  I increased the millisec delay from 1 to 5 to try 
to reduce the potential for a runaway situation:

local sHilitedelay

on openField
   if sHilitedelay is empty then put the millisec into sHilitedelay
   if the millisec - sHilitedelay > 5 then send "hiliteText" to the target in 0 
millisec
end openField

on hiliteText
  select the text of the target
  put the millisec into sHilitedelay
end hiliteText


Richmond – your solution matches the keyboard tabbing behaviour I'm after but 
not the mouse selection behaviour.


My own further idea was the following in the card script:

on openField
   -- on tabbing into a field highlight its current content:
   hiliteText
end openField

on mouseEnter
   -- on mousing into/across a field highlight its current content:
   hiliteText
end mouseEnter

on hiliteText
   put the id of the target into tID
   if there is a field id tID then
      -- select the text of field objects only:
      select the text of the target
   end if
end hiliteText

The above almost does what I want, but not quite. This method allows the user 
to use either the tab key on the keyboard or the mouse pointer to select 
another field. As the new field is selected, its current content is hilited 
ready to be replaced by any keystrokes.

Note that the user must simply move the mouse pointer into (or across) the new 
field but NOT click into it. When the user does click the mouse, it behaves 
normally and places the insertion point in the current content at the position 
of the mouse pointer at the moment of the click.

As with Mike's approach, the script for this behaviour is in the card script to 
provide the default behaviour for all fields on the card.

Peter
--
Peter Reid
Loughborough, UK

> On 20 Sep 2016, at 10:14pm, use-livecode-requ...@lists.runrev.com wrote:
> 
> Date: Tue, 20 Sep 2016 07:07:42 -0600
> From: Mike Bonner <bonnm...@gmail.com>
> To: How to use LiveCode <use-livecode@lists.runrev.com>
> Subject: Re: Silly Text Field Question
> Message-ID:
>       <CAG1cpSocDM5+65vekuVfd=qKWHER-+=fwnn-9bsvp4stkhy...@mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
> 
> Try this..
> 
> local sHilitedelay
> 
> on openField
> 
> -- sHilitedelay is used to avoid a weird side effect when regaining stack
> focus
> -- by clicking on a field in the card.  If a field other than the
> previously selected
> -- is clicked, it can start a runaway loop. The delay solves this problem.
> -- when experimenting you might put in a "if the shiftkey is down then exit
> to top"
> -- so you can break out of the loop if necessary, though the delay does
> appear to solve it fine.
>   if sHilitedelay is empty then put the millisec into sHilitedelay
> 
> -- use send in time so that all the housekeeping is completed before you
> try to hilite
>   if the millisec - sHilitedelay > 1 then send "hiliteText" to the target
> in 0 millisec
> 
> end openField
> 
> on hiliteText
>   select the text of the target
>   put the millisec into sHilitedelay
> end hiliteText

> 
> On 20 Sep 2016, at 10:14pm, use-livecode-requ...@lists.runrev.com wrote:
> 
> Date: Tue, 20 Sep 2016 23:29:25 +0300
> From: Richmond <richmondmathew...@gmail.com>
> To: How to use LiveCode <use-livecode@lists.runrev.com>
> Subject: Re: Silly Text Field Question
> Message-ID: <3960ebe8-2e97-572a-941f-b96a97345...@gmail.com>
> Content-Type: text/plain; charset=windows-1252; format=flowed
> 
> Well, I missed something as well.
> 
> I just put this script in the cardScript:
> 
> on openCard
>    set the autoTab of fld "f1" to true
>    set the autoTab of fld "f2" to true
>    set the autoTab of fld "f3" to true
>    set the autoTab of fld "f4" to true
> end openCard
> 
> and everything works . . . even if I did lose my temper several times.
> 
> https://www.dropbox.com/s/rnnj9rxla17ij8j/Text%20Hop.livecode.zip?dl=0
> 
> Richmond.
> 

_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to