Native scroller giving troubles

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

Scoperzor
Posts: 78
Joined: Tue Jan 27, 2015 1:10 pm

Native scroller giving troubles

Post by Scoperzor » Thu Jul 02, 2015 12:59 pm

Hi all.

I have a native scroller set up for an iPad application. I have managed to get it to successfully scroll and bounce, but am having the following issues:
  • 1) Upon first opening the page which contains the scroller, the buttons within the scroller group (scroller content) do not work. However, if I scroll the group a little bit, and then push the buttons, they work after that.
    2) Sometimes the scroller group bounce stops at the wrong place. For example, there should be no gap at the top of the screen (where its rect is set to), but it ends up stopping too far down the page, much lower than its initial position, thus leaving me unable to see a bottom portion of the group.
Anyone experience these issues? I have quite a lot of code involved in creating the groups and scroller, so if someone could request portions of it rather than me pasting everything from the get go.

zaxos
Posts: 222
Joined: Thu May 23, 2013 11:15 pm

Re: Native scroller giving troubles

Post by zaxos » Thu Jul 02, 2015 1:52 pm

Even tho i have no experience with mobiles i can still offer my suggestions:
first of all i think you should set the lockLoc of your group to true because groups tends to get bigger than the contents.
second of all you could make an update function for the scroller on open page that fixes the scroller, manualy set the position of the scroller on startup maybe?
Knowledge is meant to be shared.

Scoperzor
Posts: 78
Joined: Tue Jan 27, 2015 1:10 pm

Re: Native scroller giving troubles

Post by Scoperzor » Tue Jul 07, 2015 10:08 am

I have tried every combination of setting of the size lock to the scroller group and content group, as well as setting the size and location of the content group after items have been created within it. I know it's a combination of things to do with the relative sizes and the properties specified under MobileControlSet, but I can't seem to figure it out.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Native scroller giving troubles

Post by jmburnod » Tue Jul 07, 2015 10:51 am

Hi Scoperzor,

Do you move your scroller group ?
https://alternatic.ch

Scoperzor
Posts: 78
Joined: Tue Jan 27, 2015 1:10 pm

Re: Native scroller giving troubles

Post by Scoperzor » Tue Jul 07, 2015 11:54 am

The size/position of the scroller group is fixed to a portion of the page. The size of the content group within it changes, and this is what moves up and down the page.

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

Re: Native scroller giving troubles

Post by Dixie » Tue Jul 07, 2015 12:09 pm

Would you like to post your code ?

Scoperzor
Posts: 78
Joined: Tue Jan 27, 2015 1:10 pm

Re: Native scroller giving troubles

Post by Scoperzor » Tue Jul 07, 2015 12:25 pm

Up to this point, I can get it to scroll, but if the content group is scrolled up it does not reset to its initial position (i.e. top of the group gets cut off) and the buttons still only work after scrolling the group once. (So basically problem 1 from the initial post, and the opposite of problem 2). If I change the top in tContentRect I can get it to a more correct height but never one that is perfect after both down and up scrolls, and still no button joy.

Code: Select all

on scrollSet
   
   put taskPageRow*333 into tHeightScroll
   if tHeightScroll < 920 then
      put 920 into tHeightScroll
   end if
   set the height of group "taskcard_group" to tHeightScroll
   set the top of group "taskcard_group" to 122
   put the rect of group "taskcard_scroller" into tScrollerRect
   put 0,0,760,tHeightScroll into tContentRect
   
   if the environment is "mobile" then
      
      lock screen
      set the unboundedHScroll of group "taskcard_scroller" to false
      set the unboundedVScroll of group "taskcard_scroller" to true
      
      mobileControlCreate "scroller"
      put the result into sScrollerId
      
      -- general properties
      mobileControlSet sScrollerId, "rect", tScrollerRect
      mobileControlSet sScrollerId, "contentRect", tContentRect
      mobileControlSet sScrollerId, "visible", true
      mobileControlSet sScrollerId, "pagingEnabled", false
      mobileControlSet sScrollerId, "canScrollToTop", true
      mobileControlSet sScrollerId, "vIndicator", false
      mobileControlSet sScrollerId, "hIndicator", false
      mobileControlSet sScrollerId, "canBounce", true
      mobileControlSet sScrollerId, "enabled", true
      
      unlock screen
      
   end if
end scrollSet

on closeCard
   // Delete the scroller
   if the environment is "mobile" then 
      mobileControlDelete sScrollerId
   end if
end closeCard

on scrollerDidScroll hOffset, vOffset
   // When the user scrolls move the displayed content
   set the vScroll of group "taskcard_scroller" to vOffset
end scrollerDidScroll

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

Re: Native scroller giving troubles

Post by Simon » Tue Jul 07, 2015 7:36 pm

Hi Scoperzor,
Anyone experience these issues?
Yes I have but the bad news is I've forgotten how I fixed it :oops:
Couple things though;
I always place a graphic rectangle (opaque, maybe blendLevel 99) behind all the objects in the scrolling group and re-size it as needed to the formattedHeight/Width of the group. This helps as when you touch an empty part of the group it doesn't scroll and I think it helps set the size of the group.
Maybe you could try a little "bounce" right after making the group using
set the vScroll of grp "myGroup" to 20
set the vScroll of grp "myGroup" to 0

Sorry if neither of those solve it for you.

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

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Re: Native scroller giving troubles

Post by SparkOut » Tue Jul 07, 2015 8:43 pm

Are you including a datagrid in the scrolled content at all?
If so, you need to calculated the height of the scrolling group with reference to the dgFormattedHeight as part of the overall group height, not just leave it to the formattedHeight of the group.
If that's not it, I'm not sure what to suggest.

Scoperzor
Posts: 78
Joined: Tue Jan 27, 2015 1:10 pm

Re: Native scroller giving troubles

Post by Scoperzor » Wed Jul 08, 2015 6:40 am

Simon - thanks for the suggestions. I tried both the graphic background and the manual bounce. The background didn't actually change the way my scroller worked, it still scrolls regardless of which part of the scroller I select as my content group fills up all of the scroller's space. Setting the vScroll also strangely didn't seem to do the job that physically scrolling the group with my finger did.

SparkOut - I don't have a datagrid in that group or even on the page at all.

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Re: Native scroller giving troubles

Post by SparkOut » Wed Jul 08, 2015 7:11 am

Another idea, check the properties of the group and make sure the margins are set to 0

Scoperzor
Posts: 78
Joined: Tue Jan 27, 2015 1:10 pm

Re: Native scroller giving troubles

Post by Scoperzor » Wed Jul 08, 2015 7:37 am

Margins changed to 0, no change.

Can I perhaps get clarity on something - the scroller group rect is now 7,118,757,898 and the content group rect is 4,122,764,1042. I use the scroller group rect for tScrollerRect in the MobileControlSet, "rect" command, and 0,138,768,tHeightScroll for the "contentRect" command. Do these values make sense to use, relatively speaking? I'm not sure whether one needs to be larger than another. In another sample stack I've seen, the contentRect was set to values outside of the rect in the MobileControlSet commands and that functioned correctly, albeit using a datagrid rather than dynamically created groups.

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Re: Native scroller giving troubles

Post by SparkOut » Wed Jul 08, 2015 8:01 am

I believe the contentRect is relative to the scroller text, so 0,0,the formattedWidth of group "content", the formattedHeight of group " content" is more likely to work. When I am not just on this phone I shall try and test a few things on android, but I don't have any apple machine or device.

Scoperzor
Posts: 78
Joined: Tue Jan 27, 2015 1:10 pm

Re: Native scroller giving troubles

Post by Scoperzor » Wed Jul 08, 2015 8:46 am

Well that's weird then, because if I set the contentRect to that, my content group can scroll up to the top of the stack (i.e. top of 0, rather than the top of the scroller group, which is 118). The scrolling definitely works correctly when I set the contentRect to 0,138,768,tHeightScroll.

Either way, regardless of 1) what I set the contentRect to, 2) whether or not I manually set vScroll (as Simon suggested), or 3) even the layers of the buttons to the top of the card, the buttons in the content group still do not work.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Native scroller giving troubles

Post by jacque » Wed Jul 08, 2015 7:48 pm

Typically the contentRect is:

Code: Select all

 0,0,the formattedWidth of fld x, the formattedHeight of fld x
That is, it represents the entire dimensions of the field as though it were large enough to display all the text without a scrollbar.

The scroller rect can be anything; it is the frame around the visible portion of the text.

To make sure scrolling syncs, set the vscroll of the field to 0 and the vscroll of the scroller to 0 during scroller creation. After the scroller has been created you can reset the scrolls to whatever you want if necessary. If your field also needs to scroll horizontally, set both hScroll properties to 0 too.

EDIT: I just noticed you're scrolling a group. The concept is the same, just substitute "group" for "field" in the example. Sparkout had it right.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply