Drag-scrolling a group
Devin Asay
devin_asay at byu.edu
Thu Jul 11 14:00:53 EDT 2013
Hi all,
Has anyone worked out a method for drag-scrolling a group? I have a simple game in which play area may be smaller than the working screenrect on some screens. I lock the group so that it's always the same size as the stack window, then I just set the scroll of the group to show part of the play area that is in view. I've worked out how to do it using the scroll wheel on the mouse, but I also want to be able to drag the play area around with the mouse. It's "sort of" working, but is moving very jerkily.
I'm doing this:
local sDragging, sMouseV, sMouseH
on mouseUp
put false into sDragging
end mouseUp
on mouseRelease
put false into sDragging
end mouseRelease
on mouseDown
if the height of this stack < the maxHeight of this stack OR \
the height of this stack < the maxHeight of this stack then
put true into sDragging
else
put false into sDragging
end if
put the mouseV into sMouseV
put the mouseH into sMouseH
end mouseDown
on mouseMove pNewMouseH, pNewMouseV
if sDragging then
set the hScroll of me to the hScroll of me - (pNewMouseH -sMouseH)
set the vScroll of me to the vScroll of me - (pNewMouseV - sMouseV)
end if
end mouseMove
My math brain is not very sharp today. Ideas?
Thanks,
Devin
Devin Asay
Learn to code with LiveCode University
http://university.livecode.com
More information about the use-livecode
mailing list