Page 1 of 1
Native Scroll Field length
Posted: Tue Apr 15, 2014 4:12 am
by saviour
Hi guys,
Learning Livecode and it is fun as all. I am facing issues with Native Scroller. I have some text file contents needs to be imported in field "text" which is scrollable in group "scrollArea". As long as the text content is small, there is no problem with scroller and it does fine. But when text size is bigger for same file, either upper or lower part of file goes out of display. Worst is, when content is long, scroller does not work (seems jammed at bottom). I refer to some post regarding the same in the forum, but cannot find an working answer.
I think "formatted height" property of the field is already set when creating the scroller. So field "text" should adjust its length (height) according to its content (either for bigger content or file length increases when text size gets bigger). Isn't it so? Please help me out with necessary codes. Thanks

Re: Native Scroll Field length
Posted: Tue Apr 15, 2014 4:46 am
by Simon
Hi saviour,
I think you should "mobileControlDelete "scroller", "loremScroll""control before adding new text in, then recreate the control.
I found this line seems to work better than the other one in the lesson.
http://lessons.runrev.com/s/lessons/m/4 ... ll-a-field
Code: Select all
[code]put 0,0,(the formattedWidth of group "scrollArea"),(the formattedHeight of group "scrollArea") into tContentRect
[/code]
Tell me if that works out for you if not we can try something else.
Simon
Re: Native Scroll Field length
Posted: Tue Apr 15, 2014 3:18 pm
by saviour
Hi Simon.
Thank you. My problem is solved PARTIALLY. Now, problem of hidden text in upper part of field is solved, even if text size is increased.
Now, what to be done for bottom part if text is longer? Only solution seems to me is to set height of field "text" to very high number. But it will not look nice as there will be unnecessary space at the end of each file. IS there any solution so that height of field "text" is automatically adjust/resize according to the length of text file being imported?? So that height becomes small for smaller file and larger for larger files.
Thanks

Re: Native Scroll Field length
Posted: Tue Apr 15, 2014 7:06 pm
by jacque
Did you try setting the scroll of both the native scroller and the field to zero after you create the native scroller?
Code: Select all
mobileControlSet sScrollerId, "vscroll", 0
set the vScroll of field "textfield" to 0
Put that at the end after you have set all other scroller properties. You do need to delete the scroller before importing new text, and then re-create it afterward.
Re: Native Scroll Field length
Posted: Thu Apr 17, 2014 3:19 am
by saviour
I have two card in my apps; one to import text while other has scroller in it. To import text, first card needs to be assessed everytime. So I thought below code in the second card delete the scroller everytime when the card is closed. Isn't it so ??
on closeCard
// Delete the scroller
if environment() is not "mobile" then exit closeCard
mobileControlDelete sScrollerID
end closeCard
Re: Native Scroll Field length
Posted: Thu Apr 17, 2014 5:36 am
by Simon
Hi saviour,
I was having trouble understanding what you were trying to do so I built you a stack;
The key was;
Code: Select all
set the height of fld 1 of grp "scrollArea" to the formattedHeight of fld 1 of grp "scrollArea"
set the topLeft of fld 1 of grp "scrollArea" to the topLeft of grp "scrollArea"
which you will see on card 2
Did I get that right?
Simon
Re: Native Scroll Field length
Posted: Fri Apr 18, 2014 3:26 am
by saviour
Hi Simon,
Thanks for your time. I was missing above code in my scripts. I will test and let you know

Re: Native Scroll Field length
Posted: Fri Apr 18, 2014 5:15 am
by saviour
Hi Simon,
Well now, I tested the stack in real device. For small text, there is no problem and it displays well in both cards any time. But for big text, the display result in card 2 (with native scroller) is different every time. Sometimes it displays and scroll well upto the full length of text. But many of times, I can't scroll down when a point is reached in the field and bottom line get hidden (like you can see in the screenshot) which is same problem I was facing earlier. I have tested with many different variations of codes but cannot solve this issue. I am rather confused that code "formatted height:" should adjust the field height according to the length of the text.
Thanks

Re: Native Scroll Field length
Posted: Fri Apr 18, 2014 5:48 am
by Simon
Here is the fix
Code: Select all
on closeCard
// Delete the scroller
if environment() is not "mobile" then exit closeCard
set the vScroll of group "scrollArea" to 0
mobileControlDelete sScrollerID
end closeCard
Simon
Edit;
Oh, and turn off the autoHilite of that fld.