Vertical scrolling of text

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Jason1234
Posts: 42
Joined: Sat Jun 18, 2011 9:20 am

Vertical scrolling of text

Post by Jason1234 » Mon Jan 14, 2013 6:14 am

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.
Windows / MAC / IOS / Android - Deployment
Build 5.5.4 / & Community Version 6.1

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Vertical scrolling of text

Post by Simon » Tue Jan 15, 2013 3:18 am

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Jason1234
Posts: 42
Joined: Sat Jun 18, 2011 9:20 am

Re: Vertical scrolling of text

Post by Jason1234 » Sat Jan 19, 2013 12:58 pm

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
Windows / MAC / IOS / Android - Deployment
Build 5.5.4 / & Community Version 6.1

Post Reply

Return to “Android Deployment”