finding & storing the field that *would* be next on closefield

J. Landman Gay jacque at hyperactivesw.com
Sat Oct 19 18:03:11 EDT 2013


On 10/19/13 2:10 PM, Dr. Hawkins wrote:
> I need to do some work when closeField happens.  Quite often, this will
> mean sending a delayed message to redraw the entire card, as the object
> whose handler is running will get deleted.  Storing the field I'm leaving
> is not to bad, but is there a clean way to store where I *would* have gone?
>
> This could come from
> * tabKey  (not too hard, but annoying to calculate)
> * a shift-tabKey
> * an arrowKey or modified arrowKey in the first/last line of a field
> * a click in another field (hmm, doesn't that make the other field "the
> target"?)
> * killing the card (OK, fine; don't need to go anywhere)
>
> is there a clean way to find "the fieldImGoingTo of me"? :)
>

All those actions would be covered with a closefield handler, so you can 
use the handler you already have to store whatever the next field would be.

Create a constant in the script that lists the active fields in order. 
On closefield, get an offset in the list for the currently closing field 
and store the next item in the list as the one you want to "go" to. If 
you're at the end of the list, store the first item. The "wrap" function 
makes cycling around the list easy.

You can do it without the constant if the active fields are all in 
sequential layering order with no label fields in between, by wrapping 
around using their numerical order. But that usually isn't the case.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com




More information about the Use-livecode mailing list