Scroller bug!?

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
DevBoyLars
Posts: 216
Joined: Wed Feb 27, 2013 9:04 pm

Scroller bug!?

Post by DevBoyLars » Tue May 14, 2013 10:44 am

Hi there,
I add a scroller to my App and it seems to work fine until I start scrolling :D

I can't scroll to end and if I try to return to the first line of text - I can't. The scroller want get back to start.

Code: Select all

//----------
//Scrollhandler
//----------

local sScrollerID


on preOpenCard
   local tScrollerRect, tContentRect
   
   // Only create a scroller on a mobile device
   if environment() is not "mobile" then exit preOpenCard
   
   
   // Set the area of the scroller
   put the rect of group "scrollArea" into tScrollerRect
   
   
   // Set the are of the content to be scrolled
   put the left of field "scrollText",the top of field "scrollText",the right of field "scrollText",the formattedHeight of field "scrollText" into tContentRect
   
   
   // Create the scroller control
   mobileControlCreate "scroller", "Scroll"
   put the result into sScrollerID
   
   
   // Set the properties of the scroller   
   mobileControlSet "Scroll", "rect", tScrollerRect
   mobileControlSet "Scroll", "contentRect", tContentRect
   mobileControlSet "Scroll", "visible", true
   mobileControlSet "Scroll", "scrollingEnabled", true
   mobileControlSet "Scroll", "vIndicator", false
   mobileControlSet "Scroll", "hIndicator", false
   mobileControlSet "Scroll", "vscroll", 0
end preOpenCard



on closeCard
   // Delete the scroller
   if environment() is not "mobile" then exit closeCard
   mobileControlDelete sScrollerID
end closeCard



on scrollerDidScroll hOffset, vOffset
   // When the user scrolls move the displayed content
   set the vScroll of group "scrollArea" to vOffset
end scrollerDidScroll
Attachments
Start.png
This is how the scroller starts
End.png
This is after scrolling to end
Start_again.png
This is, if I try to get back to the first line

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Scroller bug!?

Post by Dixie » Tue May 14, 2013 11:12 am

see the attached stack...
Attachments
textScroll.livecode.zip
(2.62 KiB) Downloaded 230 times

DevBoyLars
Posts: 216
Joined: Wed Feb 27, 2013 9:04 pm

Re: Scroller bug!?

Post by DevBoyLars » Wed May 15, 2013 10:27 am

Thank you :)

DevBoyLars
Posts: 216
Joined: Wed Feb 27, 2013 9:04 pm

Re: Scroller bug!?

Post by DevBoyLars » Wed May 15, 2013 10:22 pm

Oh no :(

Now the text appears correctly, but if I switched from one card back to another, every scroller works just one time and stops then :(

What did I wrong?

I extended your code-sample to two cards, to show you what I mean (you need to start it in the iPhone-Simulator to see it)
Attachments
textScroll.livecode.zip
(2.62 KiB) Downloaded 236 times

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Scroller bug!?

Post by Dixie » Thu May 16, 2013 12:20 am

I know... :D
It is a problem that has not been sorted out when scrolling with fields... It does not seem to be a problem when scolling groups. Instead of deleting the scroller when you leave a card, just set its visibie to false then set it to true on your return...

I've modified the stack that I posted earlier in this post... two cards, both scrollers now work...
Dixie
Attachments
TwoCardScroller.livecode.zip
(3.24 KiB) Downloaded 236 times

DevBoyLars
Posts: 216
Joined: Wed Feb 27, 2013 9:04 pm

Re: Scroller bug!?

Post by DevBoyLars » Thu May 16, 2013 8:25 am

PERFECT!!! Thanks much :)

Post Reply