Native mobile scroller for list field (dynamic content)

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

Post Reply
shoshinsha
Posts: 35
Joined: Fri Jul 18, 2014 5:17 am

Native mobile scroller for list field (dynamic content)

Post by shoshinsha » Wed Oct 08, 2014 11:35 am

I'm trying to build a scrollable list field with dynamic content. For example, the list field contains:
--
C
B
A
--

Then I can add a new data into the list, e.g. "D":
--
D
C
B
A
--

I need to recreate the scroller whenever there is an additional data, so that the content area set is long enough for scrolling.
I'm using the below code to set the scroll area:

Code: Select all

put the left of fld "list", the top of fld "list", the right of fld "list", the formattedHeight of fld "list" into tContentRect
as referred to: http://lessons.runrev.com/m/4069/l/9441 ... ll-a-field

I output the tContentRect every time I created a scroller. The top position for both the list field and scroller group is 60.
My problem is, I would get inconsistent value for [the top of fld "list"]-- sometimes "0" (16,0,224,284- all data in the list can be viewed if scrolled), and sometimes "60" (16,60,224,284- only the top-most data cannot be seen/hidden from the scroll area).

I've tried a few values on the content area but I got no luck :(

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4003
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Native mobile scroller for list field (dynamic content)

Post by bn » Wed Oct 08, 2014 12:00 pm

Hi shoshinsha,

try to set the contentRect to 0,0,the formattedWidth of field, the formattedHeight of field.

Code: Select all

put 0,0, the width of fld "list", the formattedHeight of fld "list" into tContentRect
The topLeft coordinates of the contentRect always refer to 0,0 since the contentRect is relative to the rect of the "rect".

Kind regards
Bernd

Edit: changed to the width of field "list"

shoshinsha
Posts: 35
Joined: Fri Jul 18, 2014 5:17 am

Re: Native mobile scroller for list field (dynamic content)

Post by shoshinsha » Thu Oct 09, 2014 5:40 am

Hi Bernd,

Thanks for the reply!

I've tried to set the contentRect to 0,0,the formattedWidth of field, the formattedHeight of field-- it was ok on the first data addition into the list.
However as I add more data into the list and recreate the scroller, the top most data becomes hidden.

When I scroll down till the end, I would get some whitespace below the lowest data.
And as I add more value into the list, this whitespace becomes larger, and more data on top are hidden from view.

I also found out that the scroller (of the same code) won't work if compiling with Livecode 6.6.4 rc1 and Livecode 7.0 rc2.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4003
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Native mobile scroller for list field (dynamic content)

Post by bn » Thu Oct 09, 2014 7:35 am

Hi shosinsha,

could you upload a simple stack that shows the problem? Make a stack to isolate the problem. Without further information this is hard to track down.

Just zip the stack and use the upload function of the forum.

Kind regards
Bernd

shoshinsha
Posts: 35
Joined: Fri Jul 18, 2014 5:17 am

Re: Native mobile scroller for list field (dynamic content)

Post by shoshinsha » Thu Oct 09, 2014 9:05 am

Hi Bernd,

I'm getting "Sorry, the board attachment quota has been reached." when trying to upload an attachment...

So I used dropbox shared link instead:
https://www.dropbox.com/s/7r4i9dj5pflip ... e.zip?dl=0

The stack in zip can be downloaded thru this link. Thanks!

newtronsols
Posts: 192
Joined: Tue Mar 11, 2014 12:57 pm

Re: Native mobile scroller for list field (dynamic content)

Post by newtronsols » Thu Oct 09, 2014 9:51 am

this may not work but I use:

Set the top of group "ScrollArea" to -vOffset

Even if it doesn't fix your problem it does give a much smoother scroll on Android.

I have been trying to develop a similar concept - but by cloning a group of objects to add to the scrolling group - so the contentrect increases in size - but scrolls in the same rect - but I can't get clone to work on Android for a group, ..so far. I haven't got to the scrolling bit to see if it offsets.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4003
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Native mobile scroller for list field (dynamic content)

Post by bn » Thu Oct 09, 2014 10:11 am

Hi shoshinsha,

when you change the height of a field the field will change its location.
And when you delete the scroller but it was scrolled and then you want to create a new scroller you have to reset the scroll of group "scrollArea" too

I added 2 lines to set the topLeft of field "list" to the topLeft of group "scrollArea" after changing its height and reset the vScroll of group "scrollArea"

Code: Select all

on createScroller
   local tScrollerRect, tContentRect
   
   set the height of fld "list" to the formattedHeight of fld "list"
   set the vScroll of group "scrollArea" to 0 -- added this line BN
   set the topLeft of field "list" to the topLeft of group "scrollArea" -- added this line BN
this seems to work for me

Kind regards
Bernd

shoshinsha
Posts: 35
Joined: Fri Jul 18, 2014 5:17 am

Re: Native mobile scroller for list field (dynamic content)

Post by shoshinsha » Fri Oct 10, 2014 2:18 am

It works! :D
Thank you so much Bernd for your help!

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”