simulate keystroke

J. Landman Gay jacque at hyperactivesw.com
Mon Oct 27 12:52:34 EDT 2008


Terry Judd wrote:
> Hi Larry - it might not be the ideal way to do it but it seems to work quite
> reliably here. All I have are two buttons on a stack with an empty button
> named 'cancel' that has its autohilite set to false and a button named 'run'
> that has the following script - slightly modified from the previous version
> so that you get some feedback in the message box.
> 
> ON mouseUp
>    REPEAT forever
>       wait 0 milliseconds
>       put the milliseconds
>       IF within(btn "cancel",the mouseLoc) THEN
>          put "cancel"&& the milliseconds
>          IF the mouse is down THEN
>             set the hilited of btn "cancel" to true
>             wait until the mouse is up
>             set the hilited of btn "cancel" to false
>             exit repeat
>          END IF
>       END IF
>    END repeat
> END mouseUp

The results of this can be inconsistent. The engine only checks the 
mouse state at the exact moment the line of script is running, which is 
usually just a fraction of a millisecond; that is, if the user clicks 
the mouse quickly and the "mouse is down" check isn't the line that is 
running at that precise instant, the mouse state will not be evaluated. 
A quick mouse press will often be missed.

This type of repeat loop is a good candidate for the technique on the 
web page I mentioned.

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



More information about the use-livecode mailing list