Re: scrolling field and group on android [SOLVED]

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
keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: scrolling field and group on android [SOLVED]

Post by keram » Tue May 13, 2014 2:14 pm

Hello,

I made a card with a field that is scrolling and showing the fonts on android device. Then I added another card with a group to select the color of the text and background. I used the same script for scrolling the group as the script for scrolling the field on the first card. But the group for colors selection does not scroll on android.

The code for scrolling the fonts field is on the card level:

Code: Select all

on openCard
   local tScrollerRect, tContentRect, sScrollerID
   
   // Only create a scroller on a mobile device
   if environment() is not "mobile" then 
      set vScrollbar of fld "allfonts" to true
      exit openCard
   else 
      set vScrollbar of fld "allfonts" to false
   end if
   
   // Set the area of the scroller
   put the rect of fld "allfonts" into tScrollerRect
   
   // Set the area of the content to be scrolled
   put 0,0,(the formattedWidth of fld "allfonts"),(the formattedHeight of fld "allfonts") into tContentRect
   // Create the scroller control
   mobileControlCreate "scroller", "myScroll"
   put the result into sScrollerID
   
   // Set the properties of the scroller
   mobileControlSet "myScroll", "rect", tScrollerRect
   mobileControlSet "myScroll", "contentRect", tContentRect
   mobileControlSet "myScroll", "visible", true
   mobileControlSet "myScroll", "scrollingEnabled", true
   mobileControlSet "myScroll", "vIndicator", true
   mobileControlSet "myScroll", "vscroll", 0
end openCard

on closeCard
   // Delete the scroller
   if environment() is not "mobile" then exit closeCard
   set the vScroll of fld "allfonts" to 0
   mobileControlDelete sScrollerID
end closeCard

on scrollerDidScroll hOffset, vOffset
   // When the user scrolls move the displayed content
   set the vScroll of fld "allfonts" to vOffset
end scrollerDidScroll

--on mouseUp
--   hide fld "allfonts"
--end mouseUp
and the code for scrolling the colors group (on its own card):

Code: Select all

on openCard
   local tScrollerRect, tContentRect, sScrollerID
   if the platform is "android" then
      set the vScrollbar of grp "colorList" to false
   else
      set the vScrollbar of grp "colorList" to true
   end if
   
   // Only create a scroller on a mobile device
   if environment() is not "mobile" then 
      set vScrollbar of grp "colorList" to true
      exit openCard
   else 
      set vScrollbar of grp "colorList" to false
   end if
   
   // Set the area of the scroller
   put the rect of grp "colorList" into tScrollerRect
   
   // Set the area of the content to be scrolled
   put 0,0,(the formattedWidth of grp "colorList"),(the formattedHeight of grp "colorList") into tContentRect
   
   // Create the scroller control
   mobileControlCreate "scroller", "myScroll"
   put the result into sScrollerID
   
   // Set the properties of the scroller
   mobileControlSet "myScroll", "rect", tScrollerRect
   mobileControlSet "myScroll", "contentRect", tContentRect
   mobileControlSet "myScroll", "visible", true
   mobileControlSet "myScroll", "scrollingEnabled", true
   mobileControlSet "myScroll", "vIndicator", true
   mobileControlSet "myScroll", "vscroll", 0
end openCard

on closeCard
   // Delete the scroller
   if environment() is not "mobile" then exit closeCard
   set the vScroll of grp "colorList" to 0
   mobileControlDelete sScrollerID
end closeCard

on scrollerDidScroll hOffset, vOffset
   // When the user scrolls move the displayed content
   set the vScroll of grp "colorList" to vOffset
end scrollerDidScroll


These two scripts are identical with the only difference of having fld "allfonts" in the first one and grp "colorList" in the second.

Why is the color group not scrolling?
I'm attaching the stack.

keram
Attachments
fonts.zip
(17.59 KiB) Downloaded 195 times
Last edited by keram on Tue May 13, 2014 3:03 pm, edited 1 time in total.
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: scrolling field and group on android [SOLVED]

Post by keram » Tue May 13, 2014 2:57 pm

Oh well,

I wen back to the original lesson here:
http://lessons.runrev.com/s/lessons/m/4 ... ll-a-field
and realized that I messed it up :oops:

Looked at the sample stack code and the only difference was the first 3 lines:
local sScrollerID
on openCard
local tScrollerRect, tContentRect

I thought since sScrollerID is also a local one then why not put it together with the 2 below openCard line...
Now all the fields and groups are scrolling.

keram
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

Post Reply