Accelerated touch screen scrolling

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
abanowBUSTfGf
Posts: 63
Joined: Sat Dec 22, 2012 3:01 am

Accelerated touch screen scrolling

Post by abanowBUSTfGf » Sun Feb 03, 2013 4:03 am

I've followed the online instructions to get the touch screen to move in an accelerated
fashion with the below code. I'm obviously missing something as it does not happen

#Note: this is to run on a Samsung Galaxy Tablet 2
# only the vertical scroll is required so the horizontal scroll script is commented out

on preOpenStack
set the compositorType of this stack to "software"
set the compositorTileSize of this stack to 32
set the compositorCacheLimit of this stack to (16 * 1024 * 1024)
set the layerMode of group "group id 1050" to "scrolling"
end preOpenStack

local sScrolling
local sInitialMouseX, sInitialMouseY
local sInitialHScroll, sInitialVScroll

on mouseDown
## Allow the group to scroll
put true into sScrolling

## Record the initial touch position
put item 1 of the mouseLoc into sInitialMouseX
put item 2 of the mouseLoc into sInitialMouseY

## Record the initial hScroll and vScroll
put the vScroll of me into sInitialVScroll
put the hScroll of me into sInitialHScroll
end mouseDown

on mouseMove mouseX, mouseY
## If the screen is being touched then
if sScrolling then
## Calculate how far the touch has moved since it started
put mouseY - sInitialMouseY into tVChange
# put mouseX- sInitialMouseX into tHChange
## Reset the hScroll and vScroll to follow the touch
lock screen
set the vScroll of me to sInitialVScroll - tVChange
# set the hScroll of me to sInitialHScroll - tHChange
unlock screen
end if
end mouseMove

on mouseRelease
mouseUp
end mouseRelease

on mouseUp
put false into sScrolling
end mouseUp

abanowBUSTfGf
Posts: 63
Joined: Sat Dec 22, 2012 3:01 am

Re: Accelerated touch screen scrolling

Post by abanowBUSTfGf » Sun Feb 03, 2013 5:39 am

I have a single very long vertical image that I want to momentum scroll up and
down. Is there any Livecode script for this. Currently, dragging the finger up and
down the screen is very slow. I'm deploying on a Samsung Galaxy tablet.
Regards

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Accelerated touch screen scrolling

Post by jacque » Mon Feb 04, 2013 12:01 am

This is probably erroring and aborting the script:

Code: Select all

set the layerMode of group "group id 1050" to "scrolling"
Even though that appears to be the name in the inspector, it isn't. The name is empty and what you see there is the ID reference. Use either the reference alone, or better, give the group a name and refer to it that way. Either of these will work, but the second is more readable and much easier to debug later:

Code: Select all

set the layerMode of group id 1050 to "scrolling"
OR
set the layerMode of group "fieldScroller" to "scrolling" -- assuming that's what you named it
Finally, you'd get better results using a native Android scroller if you aren't already.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply