Swipe gestures on a mobile scroller

Paul Hibbert paul at livecode.org
Sat Nov 19 18:48:20 EST 2016


> On Nov 19, 2016, at 11:38 AM, J. Landman Gay <jacque at hyperactivesw.com> wrote:
> 
> Anyone have a workaround?


Kind of! I built an iOS app that needed to display some long fields of text, I built some pages based around this lesson:

http://lessons.livecode.com/m/4069/l/94412-creating-a-native-scroller-to-scroll-a-field?id=94412-creating-a-native-scroller-to-scroll-a-field

I had the same problem with navigating cards using swipe gestures because the field covered the majority of the card, I managed to work around the problem by modifying the scrollerDidScroll handler to:

on scrollerDidScroll hOffset, vOffset
// When the user scrolls horizontally, navigate in the desired direction

if the hScroll of group "scrollArea" <0 then // Detect the horizontal swipe

   moveBack // Stack handler to move back to Index card

 else if the hScroll of group "scrollArea" >0 then

   moveForward // Stack handler to move to next card

end if

// When the user swipes vertically, scroll the displayed content

set the vScroll of group "scrollArea" to vOffset

end scrollerDidScroll

To make this work I had to set these properties on the text field;
traversalOn “false”
autoHilite “false”
lock text “true”
So this may not work if you need the user to be able to modify the text unless you can give them a method of changing between edit/navigate modes.

I’ve managed to update the lesson file, it's on dropbox, so if it helps here it is for you to test:
https://www.dropbox.com/s/ak234nlwbgfko3p/Scroll%20Test.livecode?dl=0 <https://www.dropbox.com/s/ak234nlwbgfko3p/Scroll%20Test.livecode?dl=0>

It does seem to be reasonably reliable, but not if you tend to swipe too fast, I have’t tried it on Android though.

Paul


More information about the use-livecode mailing list