I'm trying to create a native Android scroller using the code below. I saved the stack as a standalone app and installed to my Android tablet but the text does not scroll.
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", "vscroll", 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
end scrollerDidScroll
How do I correct the script? The stack is here for anyone who needs to see it: native scroll in android.zip
=========
I also tried to create same kind of scrolling for a group consisting of several text fields and even with the suggestions from Mark (see below) it still does notwork.
the code is here:
local sScrollerID
on openCard
local tScrollerRect, tContentRect
// Only create a scroller on a mobile device
if environment() is not "mobile" then exit openCard
// Set the area of the scroller
put the rect of group "scrollArea" into tScrollerRect
// Set the area of the content to be scrolled
put the left of group "scrollArea",the top of group "scrollArea",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", "vscroll", 0
end openCard
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
end scrollerDidScroll
What corrections do I have to make for the group scroll to function?
The stack can be downloaded from here: native scroll in android-group.zip
================
3) Now that the scrolling for the group works properly I attempted to create same scrolling for a data grid using this code:
on openCard
local tScrollerRect, tContentRect
// Only create a scroller on a mobile device
if environment() is not "mobile" then exit openCard
// Set the area of the scroller
put the rect of group "DataGrid 1" into tScrollerRect
// Set the area of the content to be scrolled
put 0,0,(the formattedWidth of group "DataGrid 1"),(the formattedHeight of group "DataGrid 1") 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", "vscroll", 0
end openCard
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 "DataGrid 1" to vOffset
end scrollerDidScroll
But the scrolling of the data grid does not work with this code. What corrections do I have to make?
The stack can be downloaded here: DG-android native scroller.zip