More send in time
Cubist at aol.com
Cubist at aol.com
Tue Jul 1 09:28:00 EDT 2003
sez pixelbird at interisland.net:
>Howdy Cubist,
>This is the core changes you made:
>
>> if within(graphic "upScrollArea", mouseLoc()) then
>> set the vScroll of fld 1 to ((the vScroll of fld 1) + 1343) mod 1345
>> else if within(graphic "downScrollArea", mouseLoc()) then
>> set the vScroll of fld 1 to ((the vScroll of fld 1) + 1345) mod 1345
>> end if
>
>----------
>
>Problems:
>This appears to cause it to scroll 2 pixels at a time in the UP direction
>(fast but not smooth, and fixabable by turning '1343' into '1344'), but
>it doesn't work at all in the DOWN direction (nothing happens).
Yes. Looking back at my "1 to 10" examples, it's clear that I messed up
when I tweaked your handler -- there shoulda been a "1 +" in each of the two
"set the vScroll" statements.
>So, what I did was change line 4 to say:
> set the vScroll of fld 1 to ((the vScroll of fld 1) + 1345) mod 1344
>...which makes it work, apparently correctly because it doesn't jump or
>anything. I guess it starts it going down (in the correct direction for
>the mouseLoc).
>What say ye about that?
I say I apologize for my initial error, and I say *this*...
# note the "1 +"es!
if within(graphic "upScrollArea", mouseLoc()) then
set the vScroll of fld 1 to (1 + ((the vScroll of fld 1) + 1343) mod 1345)
else if within(graphic "downScrollArea", mouseLoc()) then
set the vScroll of fld 1 to (1 + ((the vScroll of fld 1) + 1345) mod 1345)
end if
...ought to do the job.
The reason for going with that silly "+ 1345" business is that you can get
away with condensing the "set the vScroll" lines into one, like so:
if within(graphic "upScrollArea", mouseLoc()) then put -2 into Direx else
put 0 into Direx
set the vScroll of fld 1 to (1 + ((the vScroll of fld 1) + 1345 + Direx)
mod 1345)
As long as this bit of code is *only* activated when the mouse is within
one of your two "xxxScrollArea"s, it should work fine. Hmmm... try this on for
size:
# in card script
on ScrollControl
if within(graphic "upScrollArea", mouseLoc()) then
ScrollDatPuppy (-2)
else if within(graphic "downScrollArea", mouseLoc()) then
ScrollDatPuppy (0)
send "ScrollControl" to me in 10 milliseconds -- adjust to taste
end ScrollControl
on ScrollDatPuppy Direx
set the vScroll of fld 1 to (1 + ((the vScroll of fld 1) + 1345 + Direx)
mod 1345)
end ScrollDatPuppy
Hope this helps...
More information about the use-livecode
mailing list