More send in time
Jan Schenkel
janschenkel at yahoo.com
Mon Jun 30 09:58:00 EDT 2003
--- Ken Norris <pixelbird at interisland.net> wrote:
> Howdy,
>
> I'm still having problems understanding 'send in
> time'
>
> I want to send continuous messages to scroll a field
> while the cursor is
> within a graphic while the mouse is down. It's been
> reiterated a number of
> times that it's not a good idea to use 'mouseWithin'
> or 'mouseStillDown' or
> 'while the mouse..' or 'until the mouse..' in Rev.
>
> As an example, here's how I would write it in a
> normal HyperTalk structure:
>
> on mouseDown
> repeat until the mouse is up
> if the mouse is within graphic 1 then
> set the vScroll of fld 1 to (the vScroll of
> fld 1) - 1
> else beep
> end repeat
> end mouseDown
>
> How should I rewrite this to get the exact same
> effect with a 'send in time'
> construct?
>
>
Hi Ken,
How about this script :
--
constant kInterval = 20
local sTracking
on mouseDown
put true into sTracking
send "Do1Scroll" to me in kInterval milliseconds
end mouseDown
on mouseUp
put false into sTracking
end mouseUp
on mouseRelease
put false into sTracking
end mouseRelease
on Do1Scroll
if sTracking then
if the mouseLoc is within graphic 1 then
set the vScroll of fld 1 to \
(the vScroll of fld 1) - 1
else beep
send "Do1Scroll" to me in kInterval milliseconds
end if
end Do1Scroll
--
Explanation:
- on mouseDown, the scrolling cycle starts
- on mouseUp or mouseRelease, the scrolling cycle ends
- Do1Scroll fires itself with a 20 ms delay, but will
do nothing if the scrolling cycle has ended, by
checking the content of the script local sTracking.
Hope this helped,
Jan Schenkel.
=====
"As we grow older, we grow both wiser and more foolish at the same time." (La Rochefoucauld)
__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com
More information about the use-livecode
mailing list