Page 1 of 1

scrollable-touch field

Posted: Mon Jan 17, 2022 11:57 pm
by Samuele
Hi, is there a way to ,make a table field, scrollable? but not with the scrollbar, but just by scrolling down or up (I'm talking for mobile obviously)
Thanks!

Re: scrollable-touch field

Posted: Tue Jan 18, 2022 11:33 am
by Klaus

Re: scrollable-touch field

Posted: Tue Jan 18, 2022 11:48 am
by Samuele

Re: scrollable-touch field

Posted: Tue Feb 01, 2022 4:51 pm
by Samuele
Hi I tried this script for a scrollable-touch field on android, it works, but not all the content of the field can be seen, after, you scroll a bit down, it ends the scrolling, before all the content is shown, was I understandable? :roll:

Code: Select all

//Scroller

on preOpenCard
   local tScrollerRect, tContentRect
   
   // Only create a scroller on a mobile device
   if environment() is not "mobile" then exit preOpenCard
   
   // Set the area of the scroller
   put the rect of group "scrollArea" into tScrollerRect
   
   // Set the are of the content to be scrolled
   put the left of field "ProvaData",the top of field "ProvaData",the right of field "ProvaData",the formattedHeight of field "ProvaData" into tContentRect
   
   // Create the scroller control
   mobileControlCreate "scroller", "RankScroll"
   
   // Set the properties of the scroller
   mobileControlSet "RankScroll", "rect", tScrollerRect
   mobileControlSet "RankScroll", "contentRect", tContentRect
   mobileControlSet "RankScroll", "visible", true
   mobileControlSet "RankScroll", "scrollingEnabled", true
   mobileControlSet "RankScroll", "vIndicator", true
   mobileControlSet "RankScroll", "vscroll", 0
end preOpenCard

on closeCard
   // Delete the scroller
   if environment() is not "mobile" then exit closeCard
   mobileControlDelete "RankScroll"
end closeCard

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

Re: scrollable-touch field

Posted: Tue Feb 01, 2022 5:01 pm
by Klaus
Hi Samuele,

you have been hit by an ugly bug: https://quality.livecode.com/show_bug.cgi?id=23177
As a workaround try to add some pixels to the (formatted)height like this:

Code: Select all

...
// Set the are of the content to be scrolled
put the left of field "ProvaData",the top of field "ProvaData",the right of field "ProvaData",(the formattedHeight of field "ProvaData" + 20) into tContentRect
...
Try with different values.


Best

Klaus

Re: scrollable-touch field

Posted: Tue Feb 01, 2022 5:53 pm
by Samuele
Klaus wrote:
Tue Feb 01, 2022 5:01 pm
you have been hit by an ugly bug: https://quality.livecode.com/show_bug.cgi?id=23177
Nooooo!
Klaus wrote:
Tue Feb 01, 2022 5:01 pm
As a workaround try to add some pixels to the (formatted)height like this:
alright thanks, i will try, but since the content of my field changes all the time (becomes more) does it help to add pixels?

Re: scrollable-touch field

Posted: Tue Feb 01, 2022 6:09 pm
by Klaus
No general solution, you will need to experiment a bit...

Re: scrollable-touch field

Posted: Tue Feb 01, 2022 7:43 pm
by stam
Klaus wrote:
Tue Feb 01, 2022 5:01 pm
you have been hit by an ugly bug: https://quality.livecode.com/show_bug.cgi?id=23177


I noticed this in your bug report:
klaus.jpg
I'm more surprised you bought your first mobile cellphone in April 2021!!!! ;) ;) ;)

Re: scrollable-touch field

Posted: Tue Feb 01, 2022 7:46 pm
by Klaus
Yo, and still have no SIM card! :-D

Re: scrollable-touch field

Posted: Tue Feb 01, 2022 9:48 pm
by stam
Klaus wrote:
Tue Feb 01, 2022 7:46 pm
Yo, and still have no SIM card! :-D
You’re my hero!!

Re: scrollable-touch field

Posted: Tue Feb 01, 2022 10:54 pm
by Samuele
Klaus wrote:
Tue Feb 01, 2022 5:01 pm
Hi Samuele,

you have been hit by an ugly bug: https://quality.livecode.com/show_bug.cgi?id=23177
As a workaround try to add some pixels to the (formatted)height like this:

Code: Select all

...
// Set the are of the content to be scrolled
put the left of field "ProvaData",the top of field "ProvaData",the right of field "ProvaData",(the formattedHeight of field "ProvaData" + 20) into tContentRect
...
Try with different values.


Best

Klaus
nooooo, i tried with this change and it remains exactly the same, meaning the field stops at the same point it stopped before the +, do i need to set something to the field or change something else maybe?
Thanks!

Re: scrollable-touch field

Posted: Wed Feb 02, 2022 11:24 am
by bn
Samuele,

could you try to set the topLeft of the contentRect to 0,0

like recommended in the first lesson Klaus pointed to

Code: Select all

put 0,0, the formattedWidth of field  "ProvaData", the formattedHeight of field "ProvaData" into tContentRect
Kind regards
Bernd

Re: scrollable-touch field

Posted: Wed Feb 02, 2022 6:54 pm
by jacque
Also, every time the field content changes you need to delete the old scroller and create a new one. If you don't want to do that you can try just changing the contentRect but I've found it easier to just start again with a fresh scroller. If you don't do that you'll also need to add more code to adjust the content alignment.