mobileControl scroller issue with Android

The place to discuss anything and everything about running your LiveCode on Android

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
seanmiller
Posts: 50
Joined: Mon Mar 03, 2014 1:17 am

mobileControl scroller issue with Android

Post by seanmiller » Tue Mar 08, 2016 11:15 pm

Howdy,

There's a glitch in my Android app that I can't figure out. I'm hoping a fellow forumite has some insight.

I have a card with a text field populated by a select call from a local mySQL database. If the text size exceeds the length of the text field, the card script resizes the field to the formattedHeight of the field. It also creates a mobile scroller. In iOS, the scroller works perfectly. In Android, the scroller loads properly. When the user scrolls down to the bottom of the text field, it still works. On leaving the card, the script deletes the scroller. It then recreates it on return to the page, with vScroll reset to 0. But when the user scrolls back up to the top, the top 2 lines of the text field are unviewable.

Here's the card script:

Code: Select all


on mouseUp
   
end mouseUp

on openCard
   setUpPassageScrolling
   hideNavBar
   set the visible of group "tabButtonRight" to false
end openCard

on closeCard
   if the environment is "mobile" then
   put mobileControls() into tMobileControls
      
         if tMobileControls contains "passageScroller" then
            mobileControlSet "passageScroller", "vScroll", "0"
      mobileControlDelete "passageScroller"
   end if
end if
end closeCard

on scrollerDidScroll hOffset, vOffset
      set the vScroll of group "passageGroup" of card "passage" to vOffset
end scrollerDidScroll

on setUpPassageScrolling
   
      set the vScroll of group "passageGroup" of card "passage" to 0
   set the vScroll of field "passageText" of card "passage" to 0
   
   if the environment is "mobile" then
         put mobileControls() into tMobileControls
      
         if tMobileControls contains "passageScroller" then
            mobileControlSet "passageScroller", "vScroll", "0"
      mobileControlDelete "passageScroller"
   end if
   end if
   
   set the height of field "passageText" of card "passage" to the formattedHeight of field "passageText" of card "passage"   
   set the top of field "passageText" of card "passage" to the top of group "passageGroup" of card "passage"
   
   if the formattedHeight of field "passageText" of card "passage" < the height of group "passageGroup" of card "passage" then
    set the vScrollbar of group "passageGroup" of card "passage" to false
   else
      
       if the platform is "iphone" then
          set the vScrollbar of group "passageGroup" of card "passage" to false
          mobileControlCreate "scroller", "passageScroller"
          put the rect of group "passageGroup" of card "passage" into tPassageGroupRect
          mobileControlSet "passageScroller", "rect", tPassageGroupRect
          put the rect of field "passageText" of card "passage" into tTextRect
          mobileControlSet "passageScroller", "contentRect", tTextRect
          mobileControlSet "passageScroller", "scrollingEnabled", true
          mobileControlSet "passageScroller", "opaque", true
          mobileControlSet "passageScroller", "vIndicator", true
          mobileControlSet "passageScroller", "canBounce", true
          mobileControlSet "passageScroller", "delayTouches", true
          mobileControlSet "passageScroller", "vScroll", "0"
          mobileControlSet "passageScroller", "visible", true
       else if the platform is "android" then
          set the vScrollbar of group "passageGroup" of card "passage" to false
          mobileControlCreate "scroller", "passageScroller"
          put the rect of group "passageGroup" of card "passage" into tPassageGroupRect
          mobileControlSet "passageScroller", "rect", tPassageGroupRect
          put the rect of field "passageText" of card "passage" into tTextRect
          mobileControlSet "passageScroller", "contentRect", tTextRect
          // mobileControlSet "passageScroller", "scrollingEnabled", true --commented out settings that follow don't work on Android
          mobileControlSet "passageScroller", "opaque", true
          mobileControlSet "passageScroller", "vIndicator", true
          // mobileControlSet "passageScroller", "canBounce", true
          // mobileControlSet "passageScroller", "delayTouches", true
          mobileControlSet "passageScroller", "vScroll", "0"
          mobileControlSet "passageScroller", "visible", true
       else
          set the layerMode of group "passageGroup" to "scrolling"
         set the vScrollbar of group "passageGroup" of card "passage" to true
         set the vScroll of group "passageGroup" of card "passage" to 0
         set the visible of group "passageGroup" of card "passage" to true
      end if
end if
   
end setUpPassageScrolling
Any suggestions?

Sean

seanmiller
Posts: 50
Joined: Mon Mar 03, 2014 1:17 am

Re: mobileControl scroller issue with Android

Post by seanmiller » Wed Mar 09, 2016 7:24 pm

I think I figured it out. I found this bit of helpful advice in the tutorial for creating a native scroller:

http://lessons.livecode.com/m/4069/l/94 ... ll-a-field
-nb, if you experience hidden text in your field after a scroll please replace the above script with :
put 0,0,(the formattedWidth of group "scrollArea"),(the formattedHeight of group "scrollArea") into tContentRect -
So here's what I did:

Code: Select all

else if the platform is "android" then
          set the vScrollbar of group "passageGroup" of card "passage" to false
          // put the rect of field "passageText" of card "passage" into tTextRect
          put 0,0,(the formattedWidth of group "passageGroup" of card "passage"),(the formattedHeight of group "passageGroup" of card "passage") into tTextRect
          put the rect of group "passageGroup" of card "passage" into tPassageGroupRect
          mobileControlCreate "scroller", "passageScroller"
          mobileControlSet "passageScroller", "rect", tPassageGroupRect
          mobileControlSet "passageScroller", "contentRect", tTextRect
          mobileControlSet "passageScroller", "opaque", true
          mobileControlSet "passageScroller", "vIndicator", true
          mobileControlSet "passageScroller", "vScroll", "0"
          mobileControlSet "passageScroller", "visible", true
This works as expected on Android.

Post Reply

Return to “Android Deployment”