Page 1 of 1

ios Scroller

Posted: Wed May 18, 2016 7:16 pm
by Jamie37
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

Re: ios Scroller

Posted: Wed May 18, 2016 7:21 pm
by Klaus
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

Re: ios Scroller

Posted: Wed May 18, 2016 7:29 pm
by Jamie37
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

Re: ios Scroller

Posted: Thu May 19, 2016 10:41 pm
by quailcreek
Do you have scrollid declared as a local variable?

local scrollid

Re: ios Scroller

Posted: Sun May 22, 2016 7:16 pm
by Jamie37
Yes scrollerid is declared as a variable but is a global variable. I have tried as local but no change.

Jamie

Re: ios Scroller

Posted: Tue Sep 13, 2016 11:31 pm
by Pistris
You need to declare your global variable everytime you use it
i don't see it declared in your code

i tested it fine