OpenField and keeping the focus on the field

Tom Johnson tom.quailcreek at gmail.com
Wed Jul 6 20:41:55 EDT 2011


Hello,
I'm running into a similar problem as another that's currently on the list.
What I'm trying to do is
keep the focus on the field where the script below lives. If I do a simple
"focus on me" or
something similar it goes into a loop of openField. If there's a way to keep
the focus
in the field please fill me in. If there's something wrong with my approach,
I'm
open to suggestions. There other fields and buttons on the card with this
field too. If
the focus stays in the field the rest of the script does work.


Thanks,
Tom


*-------------------- *

*local* nFormatChosen

*on* openField

  *if* the highlite of button "European" of *group* "Addess Format" is true
*then*

    *answer* "Choose the format" with "A" or "B" or "C" or "Cancel" as *
sheet*



    *if* it is "Cancel" *then* *exit* to top *else*

    *put* it into xFormatChosen



    *switch* xFormatChosen

      *case* "A"

        *put* "+11-("  & "1"  & ")"  & "1111" && "111111" into nFormatChosen

        *break*

      *case* "B"

        *put* "+11-" & "(" & "111" & ")" & "1111" && "1111" intonFormatChosen

        *break*

      *case* "C"

        *put* "+11-" & "[" & "1111" & "]" && "111" && "1111" intonFormatChosen

        *break*

    *end* *switch*

  *end* *if*

  *pass* openField

  *focus* *on* the target *-- This starts the loop*

*end* openField


*on* keydown pKey

  *delete* the selectedtext



  *if* the highlite of button "USA" of *group* "Addess Format" *then*

    RightFormat "+11" && "111-111-1111", pKey,the short name of me

  *else*

    *if* the highlite of button "European" of *group* "Addess Format" *then*

      RightFormat nFormatChosen ,pKey,the short name of me

    *else*

      RightFormat "+11" && "111-111-1111", pKey,the short name of me

    *end* *if*

  *end* *if*

*end* keydown



More information about the use-livecode mailing list