Page 1 of 1

Scroller Help

Posted: Wed Feb 06, 2013 11:20 pm
by KennyR
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 256 times

Re: Scroller Help

Posted: Wed Feb 06, 2013 11:48 pm
by Simon
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.

Re: Scroller Help

Posted: Wed Feb 06, 2013 11:50 pm
by KennyR
Thank you sooooo much! You have no idea how much this means! Thanks for the compliment btw!

Re: Scroller Help

Posted: Thu Feb 07, 2013 12:11 am
by KennyR
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...

Re: Scroller Help

Posted: Thu Feb 07, 2013 1:08 am
by Simon
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

Re: Scroller Help

Posted: Thu Feb 07, 2013 1:40 am
by KennyR
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

Re: Scroller Help

Posted: Thu Feb 07, 2013 10:02 pm
by jacque
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

Re: Scroller Help

Posted: Thu Feb 07, 2013 10:14 pm
by Simon
I just sneezed twice.
Don't worry I'm not sick.
I just have a Pseudocold. :D

Simon

Re: Scroller Help

Posted: Sun Feb 10, 2013 10:26 pm
by Jason1234
ScrollerTest.livecode.zip
Strange behavior
(2.71 KiB) Downloaded 253 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?

Re: Scroller Help

Posted: Tue Feb 12, 2013 10:36 pm
by Jason1234
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.