Page 1 of 1
Scrollbardrag drag
Posted: Wed Aug 05, 2009 11:24 pm
by hamlynart
Hi,
I'm a bit confused - why doesn't this work:
Code: Select all
on scrollbarDrag
if myVariable <=1 then
add 1 to fld "myField"
put 1 into myVariable
end if
put the thumbPosition of me into fld "Data"
end scrollbarDrag
Basically I'd like to use the "if" statement to execute a command just once at the beginning of the scrollbardrag but to continue with other stuff.
Any thoughts much appreciated.
Jim H
Posted: Thu Aug 06, 2009 12:03 am
by bn
Jim,
myVariable is not initialised and it does not persist. So nothing is in myVariable that could trigger your if structure (<=). In your script myVariable = "myVariable"
you can see this if you change your code to
but
since scrollbardrag is send repeatedly you will get many calls to your if structure. Just put it into a mousedown handler which is invoked at the click on the scrollbar once.
If I understand you correctly something like
Code: Select all
on scrollbarDrag
put the thumbposition of me into fld "Data"
end scrollbarDrag
on mouseDown
add 1 to field "myField"
end mouseDown
should do what you want. It counts how many times the scrollbar was clicked and gives you continously the thumbposition. (provided field "myField" was initialised to 0)
regards
Bernd
Posted: Thu Aug 06, 2009 12:21 am
by hamlynart
Bernd,
Wow - that works perfectly! I've been struggling with this for hours. You're right, it was the repeating that was causing the problem.
Many Thanks
Jim H
Posted: Thu Aug 06, 2009 8:36 am
by Klaus
Hi Jim,
hint:
The "scrollbardrag" message will also have a parameter that you can use:
Code: Select all
on scrollbardrag tValue
## this will be the current real-time value of the scrollbar = thumbpos)
put tValue into fld "Data"
end scrollbardrag
This is a tiny bit more efficient than additionally querying the thumbposition in the handler
Best
Klaus