Silly Text Field Question

Mike Bonner bonnmike at gmail.com
Tue Sep 20 09:07:42 EDT 2016


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 Tue, Sep 20, 2016 at 1:43 AM, Peter Reid <preid at reidit.co.uk> wrote:

> I know I'm missing the obvious but I just can't figure out how to get the
> following behaviour with text fields...
>
> 1. When the user presses the tab key on the keyboard, the next field is
> selected and the current content of the next field is selected (so any
> typing replaces all the content).
>
> 2. If the user uses the mouse to click into a different text field, the
> current content of the next field is selected and behaves just like 1.
>
> What's happening is that I can get 1. to work but every time the user
> mouse-clicks into a different field, that target field gets selected but
> its content is deselected and the I-bar insertion point is placed where the
> mouse click occurred.
>
> So far I've got the following in the card script to provide the same
> behaviour for all the fields on it:
>
> on openField
>  hiliteText
> end openField
>
> on hiliteText
>  put the id of the target into tID
>  if there is a field id tID then
>    select the text of the target
>  end if
> end hiliteText
>
> Any suggestions please?
>
> Peter
> --
> Peter Reid
> Loughborough, UK
>
>
> _______________________________________________
> 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