Trapping the escape key inside a loop

David Coker davidocoker at gmail.com
Tue Apr 6 22:02:07 EDT 2010


> You have to give your repeat loop a break so the system has time to
> detect the escape key.
> Try this:
>
> global gStop
>
> on mouseUp
>   put false into gStop
>   repeat with x = 1 to 1000
>      put x into fld 1
>      if gStop = true then exit repeat
>      wait 0 milliseconds with messages   -- allows detection of other events
>   end repeat
> end mouseUp
>
> And in the card or stack script:
>
> global gStop
>
> on escapeKey
>   put true into gStop
> end escapeKey

Sarah, you are now my absolute hero!
(or heroine as the case may be).

Heroine:
"...a woman of distinguished courage or ability, admired for her brave
deeds and noble qualities"

I had stared out using the false/true combo and got no place fast, so
I move to the numerical flag attempt in an act of not knowing what
else to try. Unfortunately, I never even thought about placing a wait
message inside the loop. It works great now.
Awesome!!!

Thank you very much!

David C.



More information about the use-livecode mailing list