simulate keystroke
Terry Judd
tsj at unimelb.edu.au
Mon Oct 27 02:35:31 EDT 2008
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
Terry...
On 27/10/08 3:05 PM, "Larry Watts" <lgwatts at adelphia.net> wrote:
> thanks Jacqueline,
> this is similar to a timer we use in another app. we can pause the timer by
> clicking on a different button. so tomorrow, i'll have a go at implementing
> your code here in my new app.
>
> Larry
> P.S. Terry, I tried your idea exactly as you gave it. I put it in a test
> button, but Rev behaved very inconsistently with it.
>
> ----- Original Message -----
> From: "J. Landman Gay" <jacque at hyperactivesw.com>
> To: "How to use Revolution" <use-revolution at lists.runrev.com>
> Sent: Sunday, October 26, 2008 7:11 PM
> Subject: Re: simulate keystroke
>
>
>> J. Landman Gay wrote:
>>> Larry Watts wrote:
>>>> hi Mark,
>>>> What I'm really wondering how to do is this:
>>>> I have a button script running with a lot of repeat statements in it.
>>>> Depending upon the input, the script will run for 5 minutes to an hour.
>>>> I want the user to be able to interrupt the script by clicking on
>>>> another button on the card. But as I understand it, Rev cannot do that
>>>> because the first button has the focus until the entire script is
>>>> finished running. Is there a way to work around this limitation of Rev?
>>>
>>> Yes, and the workaround is the preferred method. Running a repeat loop
>>> that long doesn't just lock up Rev, it locks up the whole CPU. Here's the
>>> preferred solution: <http://www.hyperactivesw.com/polling.html>.
>>
>> It just occured to me that your repeat loop probably doesn't track the
>> mouse, so the link I gave isn't a good reference. What I'd use instead is
>> a "send in <time>" statement that calls a handler repeatedly until the
>> work is done. This will avoid taking all the CPU cycles too, because a
>> time slice is given to other processes in between the "send"s.
>>
>> A simple example:
>>
>> on mouseUp -- the button that starts the processing
>> set the cProcessFlag of me to true
>> send "doProcess" to me in 1 millisecond -- can be adjusted
>> end mouseUp
>>
>> on doProcess
>> if <some quit condition; maybe the data is empty, etc> or \
>> the cProcessFlag of me = false then
>> set the cProcessFlag of me to false -- in case the quit condition got
>> us here
>> else
>> doSomeProcessing
>> send "doProcess" to me in 1 millisecond
>> end if
>> end doProcess
>>
>> And in the button that interrupts the processing:
>>
>> on mouseUp
>> set the cProcessFlag of btn "start button" to false
>> end mouseUp
>>
>> --
>> Jacqueline Landman Gay | jacque at hyperactivesw.com
>> HyperActive Software | http://www.hyperactivesw.com
>> _______________________________________________
>> use-revolution mailing list
>> use-revolution at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-revolution
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
--
Dr Terry Judd
Lecturer in Educational Technology (Design)
Biomedical Multimedia Unit
Faculty of Medicine, Dentistry & Health Sciences
The University of Melbourne
Parkville VIC 3052
AUSTRALIA
61-3 8344 0187
More information about the use-livecode
mailing list