Page 1 of 1

Lorem Scrolling Issue - Android

Posted: Sun Sep 11, 2016 6:43 pm
by newpie
Hello, I need some advice on performing the native scroll when resizing images. I tried multiple methods and can't seem to get scroll area to reset properly. It works fine on Button 1, but subsequent button resize does not work.
Any help would be appreciated. Thanks

Card Script:

Code: Select all

on ScrollSet
   local tScrollerRect, tContentRect
   
   // 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 img"picture" ,the top of img"picture" ,the right of img"picture" ,the formattedHeight of img"picture" into tContentRect
   ##put 0,0,(the formattedWidth of group "scrollArea"),(the formattedHeight of group "scrollArea") into tContentRect
   
   
   // Create the scroller control
   mobileControlCreate "scroller", "loremScroll"
   put the result into sScrollerID
   
   // Set the properties of the scroller
   --mobileControlSet "loremScroll", "contentRect", (0, 0, the width of img"picture", the height of img"picture")
   mobileControlSet "loremScroll", "rect", tScrollerRect
   mobileControlSet "loremScroll", "contentRect", tContentRect
   mobileControlSet "loremScroll", "visible", true
   mobileControlSet "loremScroll", "scrollingEnabled", true
   mobileControlSet "loremScroll", "vIndicator", true
   mobileControlSet "loremScroll", "hIndicator", true
   mobileControlSet "loremScroll", "vscroll", 0
   mobileControlSet "loremScroll", "hscroll", 0
end ScrollSet

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

on scrollerDidScroll hOffset, vOffset
   // When the user scrolls move the displayed content
   set the vScroll of group "scrollArea" to vOffset
   set the hScroll of group "scrollArea" to hOffset
   put "Scrolled to" && hOffset & comma & vOffset into field "scroller status" of card "home"
end scrollerDidScroll

Code: Select all

Button 1:
on mouseUp
   lock screen
   put empty into img "picture"
   set the width of img "picture"  to "7500"
   set the height of img "picture" to "3379"
   set the defaultFolder to "/mnt/extsd/Maps"
   set the topLeft of img "picture" to "0,0"
   put URL ("binfile:" & "Alpha.png") into img "picture"
   ScrollSet
   unlock screen
end mouseUp

Button 2:
on mouseUp
   lock screen
   set the width of img "picture"  to "2500"
   set the height of img "picture" to "1126"
   set the topLeft of img "picture" to "0,0"
   ScrollSet
   unlock screen
end mouseUp

Re: Lorem Scrolling Issue - Android

Posted: Sun Sep 11, 2016 9:48 pm
by jmburnod
Hi Newpie,

Code: Select all

put the left of img"picture" ,the top of img"picture" ,the right of img"picture" ,the formattedHeight of img"picture" into tContentRect
formattedwidth and formattedheight of an image doesn't change when you resize an image.
Why not :

Code: Select all

 put the rect of img "picture" into tContentRect
Best regards
Jean-Marc

Re: Lorem Scrolling Issue - Android

Posted: Mon Sep 12, 2016 4:57 am
by newpie
Hello Jean-Marc, thanks for responding, I tried changing the code and I still seem to have the problem. First Button is fine when loads, but subsequent image resizing and the picture becomes cut off from all sides depending on resize. Not sure why.

Re: Lorem Scrolling Issue - Android

Posted: Mon Sep 12, 2016 3:37 pm
by MaxV
Please note that

Code: Select all

mobileControlSet "loremScroll", "contentRect", tContentRect
tcontenct rect must always starts from 0,0.
So tContentRect is something like "0,0,200,300"

Re: Lorem Scrolling Issue - Android

Posted: Mon Sep 12, 2016 4:36 pm
by jmburnod
Sorry, I was wrong
In your case tContentRect should be
0,0, the formattedwidth of group "scrollArea",the formattedheight of group "scrollArea"

Re: Lorem Scrolling Issue - Android

Posted: Mon Sep 12, 2016 11:44 pm
by newpie
Ok, I tried reverting back to that what I had previously (below) and get the original issue of picture being cut out. Is the method I am using to change the image and reset the scroller correct (button script)?

Thanks

Code: Select all

on ScrollSet
   local tScrollerRect, tContentRect
   
   // Set the area of the scroller
   put the rect of group "scrollArea" into tScrollerRect
   
   // Set the are of the content to be scrolled
   put 0,0,(the formattedWidth of group "scrollArea"),(the formattedHeight of group "scrollArea") into tContentRect
   
   
   // Create the scroller control
   mobileControlCreate "scroller", "loremScroll"
   put the result into sScrollerID
   
   // Set the properties of the scroller
   mobileControlSet "loremScroll", "rect", tScrollerRect
   mobileControlSet "loremScroll", "contentRect", tContentRect
   mobileControlSet "loremScroll", "visible", true
   mobileControlSet "loremScroll", "scrollingEnabled", true
   mobileControlSet "loremScroll", "vIndicator", true
   mobileControlSet "loremScroll", "hIndicator", true
   mobileControlSet "loremScroll", "vscroll", 0
   mobileControlSet "loremScroll", "hscroll", 0
end ScrollSet