Scrolling and Autoscaling - How can I do both?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
cdimoff
Posts: 1
Joined: Mon Dec 23, 2013 5:07 am

Scrolling and Autoscaling - How can I do both?

Post by cdimoff » Mon Dec 23, 2013 5:11 am

Hi guys,

I was overjoyed to see "autoscaling" as part of livecode's 6.5 update. I have been able to make my apps scale/resize so much easier with only 3 lines of code. My question is how do I make my apps scale/resize with a scroller?

I can make my apps scroll just fine using the "create a native scroller to scroll text fields" tutorial

However when I add the 3 lines of code to make my apps scale/resize the "scroll area" stays small (about half of the screen) with the horizontal scroll bar staying at about halfway on the screen. I can scroll it like this (by just touching in the top half of the screen) for a while, but then it eventually stops showing the "blue haze" that indicates you have scrolled all the way-even though I still have more to go.

This is the code I use to make the stack resize:

Code: Select all

on preOpenStack
set the fullscreenmode of me to "exactFit"
end preOpenStack
Very frustrating so any/all help is appreciated! Thanks

P.S: I am testing on an android-galaxy s4 but want to make this app work on both ios and android.

splash21
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 369
Joined: Sun Dec 19, 2010 1:10 am
Contact:

Re: Scrolling and Autoscaling - How can I do both?

Post by splash21 » Mon Dec 23, 2013 11:46 am

Hi, cdimoff. Is the code definitely in the stack script? It works OK here, but if I put the code in the card script instead, it doesn't - just a thought. :)
LiveCode Development & Training : http://splash21.com

viro
Posts: 52
Joined: Fri Jul 05, 2013 6:59 pm

Re: Scrolling and Autoscaling - How can I do both?

Post by viro » Thu Jun 12, 2014 10:01 am

Sorry for digginng this one out. But I can't figure out why my textfield can scroll completly while an image does...
Attachments
Scroller_Example.zip
(55.29 KiB) Downloaded 234 times
the funniest thing about this particular signature is that by the time you realize it doesn't say anything it's too late to stop reading it

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

Re: Scrolling and Autoscaling - How can I do both?

Post by Simon » Thu Jun 12, 2014 6:39 pm

Hi viro,
The first problem is you have the size and position locked on the field "lorem", unlock that. Only the group should be locked.
For the first card put the script into an openCard handler (not preOpenCard) it seems to work better.
Yor script:
put 0,0,(the formattedWidth of field "lorem"),(the formattedHeight of field "lorem") into tContentRect
should be
put 0,0,(the formattedWidth of group "scrollArea"),(the formattedHeight of group "scrollArea") into tContentRect

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

viro
Posts: 52
Joined: Fri Jul 05, 2013 6:59 pm

Re: Scrolling and Autoscaling - How can I do both?

Post by viro » Fri Jun 13, 2014 9:20 am

Ty Simon, I followed your suggestions, Text didnt scroll to the end because it wasnt expanded to full size :roll:
Image has been misplaced in the middle, correcting it to topleft sorted out this problem too!

There's a difference when using formatted size of fld or of grp
when using grp there's plenty of whitespace after scrolling..
Attachments
Scroller Example.zip
(56.13 KiB) Downloaded 257 times
the funniest thing about this particular signature is that by the time you realize it doesn't say anything it's too late to stop reading it

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

Re: Scrolling and Autoscaling - How can I do both?

Post by Simon » Fri Jun 13, 2014 9:50 am

Try this in button "contGroup":

Code: Select all

   // Nur auf mobilen Geräten erstellen
   if environment() is not "mobile" then exit mouseup
   set the height of fld "lorem" to the formattedHeight of fld "lorem" --new line
   set the top of fld "lorem" to the top of grp "scrollArea" --newLine
   // Bereich des Scrollers
   put the rect of group "scrollArea" into tScrollerRect
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Post Reply