Horizontal Scroll
Posted: Fri Feb 28, 2014 7:12 pm
I took the lesson for a vertical scroll android field and am trying to do a horizontal scroll. Can this be done? I tried to duplicate the vertical scroll data to the horizontal scroll...but it still isn't working.
http://lessons.runrev.com/s/lessons/m/4 ... ll-a-field
I put the code I added in bold/red. I also changed the field in the lesson to a non wrap field expecting to be able to scroll through it horizontally.
Here is the code:
local sScrollerID
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 "lorem",the top of field "lorem",the right of field "lorem",the formattedHeight of field "lorem" 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 preOpenCard
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
end scrollerDidScroll
Thanks for any help!
Kosmo
http://lessons.runrev.com/s/lessons/m/4 ... ll-a-field
I put the code I added in bold/red. I also changed the field in the lesson to a non wrap field expecting to be able to scroll through it horizontally.
Here is the code:
local sScrollerID
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 "lorem",the top of field "lorem",the right of field "lorem",the formattedHeight of field "lorem" 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 preOpenCard
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
end scrollerDidScroll
Thanks for any help!
Kosmo