Native scrolling a group with dynamic content

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
SparkOut
Posts: 2943
Joined: Sun Sep 23, 2007 4:58 pm

Native scrolling a group with dynamic content

Post by SparkOut » Sat May 09, 2015 5:51 pm

Does anyone have a neat way of using a native scroller to scroll a group (containing other groups) with elements that may show or hide depending on interaction?
If I set the visibility of the items then I need to reset (destroy and recreate) the scroller, otherwise it goes haywire, even though the elements shown and hidden are the same size and location. If I recreate the scroller, the scroll location jumps to the top and the page layout skips, so the user has to scroll back to the original place. I have tried saving the current vscroll property of the scroller with mobileControlGet (tScrollerID,"vscroll") and then destroying and recreating the scroller, then using the saved value with mobileControlSet tScrollerId, "vscroll", tVscroll. For good measure I have also set the vScroll of group "ScrollingGroup" to tVscroll. It kind of works every so often, but mostly just leaves a haywire scroller working on different parts of the scrolling group.
Any advice?
Thanks

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

Re: Native scrolling a group with dynamic content

Post by jacque » Sun May 10, 2015 5:37 pm

I think the only choice is to do what you're doing now. A scroller is just a way of caching content in memory so that it can be moved smoothly. If the content changes then the cached version has to be updated in RAM.

Each change will require that you treat it like a new scroller. Store the current scroll of the group in a variable for later reference, then destroy the scroller, change the group content, set the group scroll to 0, create the new scroller, and finally set the scroll of both the group and the scroller to the saved variable value. Lock the screen during the process for speed and cosmetics.

It would be nice to have a way to refresh the scroller content without recreating it but I don't recall any way to do that offhand.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: Native scrolling a group with dynamic content

Post by SparkOut » Sun May 10, 2015 10:45 pm

The thing is, having recreated the scroller, setting its vscroll and that of the group doesn't give reliable results. It would be nice if switching the visibility of different controls of the same rect worked, but that upsets the scroller. I have discovered this evening that switching the blendLevel from 0 to 99 and vice versa does actually seem to work.

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

Re: Native scrolling a group with dynamic content

Post by jacque » Sun May 10, 2015 11:15 pm

That's really odd. I wouldn't have thought the blendlevel would matter. Interesting.

When I first worked through a similar issue a long time ago, I found the key was to reset the group scroll to zero before creating the scroller. But if the blendlevel trick works, maybe that's enough. It's a weird side effect though.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply