Page 1 of 1

Vertical scrolling of text

Posted: Mon Jan 14, 2013 6:14 am
by Jason1234
This has been discussed but not that I could find specific for a standard text field.

All I am trying to do is touch scroll the text vertically. I have almost got it working but each time you press the screen it jumps to the original start position instead of the finished position. Effectively not scrolling all the way.

Below is a code snippet taken from a lesson.

Code: Select all

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
I have tried recording the final position and then applying that as the start but no luck. Can anyone see how this could work?

This is again one of those fundamental features needed for mobile deployment. You need to be able to scroll vertically using touch.

Hope someone can help.

Re: Vertical scrolling of text

Posted: Tue Jan 15, 2013 3:18 am
by Simon
Have you looked up AndroidScroller in the dictionary?
I think it works better than using a desktop version.

Simon
EDIT: Here
http://forums.runrev.com/phpBB2/viewtop ... er+#p64051

Re: Vertical scrolling of text

Posted: Sat Jan 19, 2013 12:58 pm
by Jason1234
Thank you. Sometimes it's just knowing what these controls are actually called. Runrev have since updated a lesson so all sorted.

Thanks again for the advice