ios Scroller

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: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
Jamie37
Posts: 53
Joined: Sat Dec 19, 2015 1:45 pm

ios Scroller

Post by Jamie37 » Wed May 18, 2016 7:16 pm

Hello,

I am having issues with scrolling a field in ios on an iPad. I am using this code example from Dixie http://forums.livecode.com/viewtopic.php?f=49&t=7991. The problem I am having is that the scroller works fine when I first go onto the card. However, when I navigate away from it and come back it will not work at all. When I move my finger to scroll, it will just highlight the options rather than scrolling. I have tried various ways to overcome the problem but nothing seems to be working. Hopefully somebody can help.

Thanks
Jmaie

Klaus
Posts: 11203
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: ios Scroller

Post by Klaus » Wed May 18, 2016 7:21 pm

Hi Jamie,

quick guess:
You do delete the native scroller when closing the card, do you?

This does not happen automatically and I don't know what happens
if there are multiple identical scrollers on the same card.



Best

Klaus

Jamie37
Posts: 53
Joined: Sat Dec 19, 2015 1:45 pm

Re: ios Scroller

Post by Jamie37 » Wed May 18, 2016 7:29 pm

Hi Klaus,

Thanks for the reply. I believe so, Here is the code I am using on the card script:

Code: Select all

on preOpenCard
   if environment() is not "mobile" then exit preOpenCard
   put the rect of fld "DropBoxFileList" into fldRect
   put the formattedHeight of fld "DropBoxFileList" into fldHeight
   put the width of fld "DropBoxFileList" into fldWidth
   
   set the height of fld "DropBoxFileList" to fldHeight
   set the unboundedVScroll of group "raScrollingField"  to true
   
   mobileControlCreate "scroller"
   put the result into scrollid
   
   mobileControlSet scrollid, "rect", fldRect
   mobileControlSet scrollid, "contentRect", (0, 0, fldWidth, fldHeight)
   mobileControlSet scrollid, "visible", "true"
   mobileControlSet scrollid, "canBounce", "true"
   mobileControlSet scrollid, "declerationRate", "fast"
   mobileControlSet scrollid, "scrollingEnabled", "true"
   mobileControlSet scrollid, "canScrollToTop", "true"
   mobileControlSet scrollid, "canCancelTouches", "false"
   mobileControlSet scrollid, "delayTouches", "true"
   mobileControlSet scrollid, "vIndicator", "true"
   mobileControlSet scrollid, "indicatorStyle", "black"
   mobileControlSet scrollid, "indicatorInsets",  "0,0,0,0"
   mobileControlSet scrollid, "hscroll", 0
   mobileControlSet scrollid, "vscroll", 0
   
   repeat with count = 1 to the number of lines of fld "DropBoxFileList"
      set the textShift of line count of fld "DropBoxFileList" to - 10
   end repeat
end preOpenCard

------------------------------------------------------------------------------
------------------------------------------------------------------------------

on scrollerBeginDrag
   set the hilitedLine of fld "DropBoxFileList" to empty
end scrollerBeginDrag

on scrollerScrollToTop
   mobileControlSet scrollId, "vscroll", 0
end scrollerScrollToTop

on scrollerDidScroll hOffset, vOffset
   set the vScroll of group "raScrollingField" to vOffset
end scrollerDidScroll

------------------------------------------------------------------------------
------------------------------------------------------------------------------

on closeCard
   if environment() is not "mobile" then exit closeCard
   mobileControlDelete scrollid
end closeCard

Hopefully That helps a bit but I delete the scrollid on the closeCard.

Thanks
Jamie

quailcreek
Posts: 746
Joined: Sun Feb 04, 2007 11:01 pm
Location: McKenna, WA

Re: ios Scroller

Post by quailcreek » Thu May 19, 2016 10:41 pm

Do you have scrollid declared as a local variable?

local scrollid
Tom
MacBook Pro OS Mojave 10.14

Jamie37
Posts: 53
Joined: Sat Dec 19, 2015 1:45 pm

Re: ios Scroller

Post by Jamie37 » Sun May 22, 2016 7:16 pm

Yes scrollerid is declared as a variable but is a global variable. I have tried as local but no change.

Jamie

Pistris
Posts: 126
Joined: Mon Jul 20, 2015 2:40 am

Re: ios Scroller

Post by Pistris » Tue Sep 13, 2016 11:31 pm

You need to declare your global variable everytime you use it
i don't see it declared in your code

i tested it fine

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”