Lorem Scrolling Issue - Android

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
newpie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 155
Joined: Sat Jun 29, 2013 11:24 pm

Lorem Scrolling Issue - Android

Post by newpie » Sun Sep 11, 2016 6:43 pm

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

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Lorem Scrolling Issue - Android

Post by jmburnod » Sun Sep 11, 2016 9:48 pm

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
https://alternatic.ch

newpie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 155
Joined: Sat Jun 29, 2013 11:24 pm

Re: Lorem Scrolling Issue - Android

Post by newpie » Mon Sep 12, 2016 4:57 am

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.

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: Lorem Scrolling Issue - Android

Post by MaxV » Mon Sep 12, 2016 3:37 pm

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"
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Lorem Scrolling Issue - Android

Post by jmburnod » Mon Sep 12, 2016 4:36 pm

Sorry, I was wrong
In your case tContentRect should be
0,0, the formattedwidth of group "scrollArea",the formattedheight of group "scrollArea"
https://alternatic.ch

newpie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 155
Joined: Sat Jun 29, 2013 11:24 pm

Re: Lorem Scrolling Issue - Android

Post by newpie » Mon Sep 12, 2016 11:44 pm

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

Post Reply