Scroller Help

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
KennyR
Posts: 256
Joined: Thu Jan 19, 2012 4:25 am

Scroller Help

Post by KennyR » Wed Feb 06, 2013 11:20 pm

I was hoping someone could explain to me what is going on here... I have a mainstack with 4 cards that each have a ios native scroller on each card. That scroller holds a multitude of buttons that need to be scrolled. My scroller works fine for the most part, but when I visit another card and come back to the previous card, the scroller moves all the buttons down and there is an empty space above the buttons. It is always a empty space the distance that the group was previously scrolled. I could actually get something done on the program if I could get this problem solved. I am attaching my stack and asking that someone PLEASE take a look and take pity on me...I'm frustrated and ready to give up...thanks in advance...
JCASmobile.livecode.zip
(195.28 KiB) Downloaded 253 times

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

Re: Scroller Help

Post by Simon » Wed Feb 06, 2013 11:48 pm

Hi Kenny,
Nice looking app.
Add this to all your scrolling cards:

Code: Select all

on closeCard
set the vScroll of group "kScroll" to 0
mobileControlDelete sScrollerID
end closeCard
Well depending on what you name your other groups.

Simon
EDIT:
Actually I think setting the vScroll should take place in the preOpenCard but keep the mobileControlDelete in the closeCard.
Last edited by Simon on Wed Feb 06, 2013 11:56 pm, edited 1 time in total.
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

KennyR
Posts: 256
Joined: Thu Jan 19, 2012 4:25 am

Re: Scroller Help

Post by KennyR » Wed Feb 06, 2013 11:50 pm

Thank you sooooo much! You have no idea how much this means! Thanks for the compliment btw!

KennyR
Posts: 256
Joined: Thu Jan 19, 2012 4:25 am

Re: Scroller Help

Post by KennyR » Thu Feb 07, 2013 12:11 am

on another note, I keep noticing that the scroller shifts upwards about the height of 1 button when the group is scrolled causing me to lose the very top button. When I navigate to another card and come back the scroller resets and the button reappears. What could be causing that?

P.S the other problem is now fixed...thanks again for the help...

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

Re: Scroller Help

Post by Simon » Thu Feb 07, 2013 1:08 am

Hi Kenny,
I've got a workaround but I think this needs to be looked at more carefully.
in your preOpenCard
put the left of group "kGroup", the top of group "KGroup" - 44, ...
Fixes it, but I have not figured out why it needs that so not really advisable.

It's odd and probably a clue that it is exactly 1 button height.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

KennyR
Posts: 256
Joined: Thu Jan 19, 2012 4:25 am

Re: Scroller Help

Post by KennyR » Thu Feb 07, 2013 1:40 am

Hey Simon,
Well, if you noticed in my script, I have been including mobGUI in my design and I have to say that the program causes TONS of headaches...I am trying to phase out mobGUI due to all the bugs that comes with it....I'm a rookie and the program helped at first, but I see now it's just not worth the hassle. Thanks for the work around...I'll give it a shot and see what happens...Initially I tried what you are suggesting, but when I gained the button back at the top of the scroller, I lost the lower button in the scroller....Needless to say, I have been using quite a few four letter words to voice my frustrations.... :0

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7254
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Scroller Help

Post by jacque » Thu Feb 07, 2013 10:02 pm

The trick seems to be to recreate everything from scratch in preOpenCard. Continue to delete the scroller on closeCard.

When you recreate the scroller, the vScroll of the group should be set to 0 before you create the native scroller. That aligns everything. If you want the previous scroll to remain, store it in a variable first. Pseudocode:

Store the current scroll of the group in a variable (if you need it)
Set the vScroll of the group to zero
Create the native scroller
Set the scroll of the native scroller to the saved scroll
Set the scroll of the group to the saved scroll
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: Scroller Help

Post by Simon » Thu Feb 07, 2013 10:14 pm

I just sneezed twice.
Don't worry I'm not sick.
I just have a Pseudocold. :D

Simon
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: Scroller Help

Post by Jason1234 » Sun Feb 10, 2013 10:26 pm

ScrollerTest.livecode.zip
Strange behavior
(2.71 KiB) Downloaded 249 times
I have attached a sample stack where I have duplicated the code exactly as per the lesson. I have added the buttons to demo the odd behavior of the scroll.

Viewed on a small phone 320 x 470

This is not working correctly in that when the first enter the field it will scroll down but sometimes not allow you to see the first part of the text after the scroll. If you leave the card and re-enter the text moves down then allows you to see the top part again.

I have tried adding the code suggested but nothing seems to help with the text chopping after scroll.

Can anyone see what might help keep the text to the top and not chop the first part off after the scroll?
Windows / MAC / IOS / Android - Deployment
Build 5.5.4 / & Community Version 6.1

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

Re: Scroller Help

Post by Jason1234 » Tue Feb 12, 2013 10:36 pm

Issue Solved via Runrev support.

For the benefit of anyone else who has the same issue.

Use this code in the PreOpenCard handler instead of the lesson one.

Code: Select all

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 0,0,(the formattedWidth of group "scrollArea"),(the formattedHeight of group "scrollArea") into tContentRect

  // Create the scroller control
  mobileControlCreate "scroller", "loremScroll"
  put the result into sScrollerID

  // Set the properties of the scroller
  mobileControlSet "loremScroll", "rect", tScrollerRect
  mobileControlSet "loremScroll", "contentRect", tContentRect
  mobileControlSet "loremScroll", "visible", true
  mobileControlSet "loremScroll", "scrollingEnabled", true
  mobileControlSet "loremScroll", "vIndicator", true
  mobileControlSet "loremScroll", "vscroll", 0

end preOpenCard
Adjusting the value that is placed into tContentRect, to both the formattedWidth
and Height of the group "scrollArea" seems to resolve the issue.
Windows / MAC / IOS / Android - Deployment
Build 5.5.4 / & Community Version 6.1

Post Reply

Return to “iOS Deployment”