Widget request (native text scroller for iOS)

J. Landman Gay jacque at hyperactivesw.com
Wed Nov 30 15:34:32 EST 2016


On 11/30/16 7:35 AM, John Allijn wrote:
> I can’t get the scroller working

I haven't had any problem with scrollers on either iOS or Android, 
barring a specific vScroll bug that's been reported. 
(http://quality.livecode.com/show_bug.cgi?id=18924)  Aside from that 
they work very well as long as you follow the instructions here:

<http://lessons.livecode.com/m/4069/l/94412-creating-a-native-scroller-to-scroll-a-field?id=94412-creating-a-native-scroller-to-scroll-a-field>

Scrollers are picky, you have to make sure that:

1. The full length of the field is displayed. It can't be a scrolling 
field, it has to be a very tall field at its full height so all content 
is visible. It's okay if it runs off the window.
2. The field must have lockloc set to true.
3. The field must be in a group, and generally it's the only thing in 
the group. The group should be sized to the rectangle you want the user 
to see. It's lockloc must be set to true.
4. For now (until the bug is fixed) the vScroll of the group should be 
set to 0 when the mobile scroller is created, and the mobile vScroll 
should also be 0. (A workaround is in the bug report if you want to set 
the vScroll to something else.)

I have a simplified handler that creates a mobile scroller which has 
been working for a long time. The only parameter it needs is the short 
name of the group that contains the field. (The content of the group 
doesn't have to be a field, it can be an image or anything else.)

I find that using names instead of IDs is much easier because you don't 
have to bother with "the result" or track the reference in a script 
local. It just works, provided each scrolling group has a unique name. 
When you want to delete the scroller you can also just use the name. 
This handler automatically creates a scroller with the same name as the 
group it is scrolling.

command createScroller pName
   if the environment is not "mobile" then exit createScroller
   deleteMobileControl pName -- custom handler, in case one already exists
   set the vScroll of control pName to 0 -- init for alignment
   set the hScroll of control pName to 0
   mobileControlCreate "scroller", pName
   mobileControlSet pName, "rect", the rect of control pName
   put  (0,0,the formattedwidth of control pName,the formattedheight of 
control pName) into tRect
   mobileControlSet pName, "contentRect",tRect
   mobileControlSet pName, "hScroll",0
   mobileControlSet pName, "vScroll",0
   mobileControlSet pName, "hIndicator",false
   mobileControlSet pName, "vIndicator",true
   mobileControlSet pName, "visible", true
end createScroller

This is enough to create a basic scroller. There are other settings you 
might want to add for iOS, such as the canBounce, etc., and you may want 
to change the v and h indicator settings. Adding more settings is easy, 
but the above does the basic work.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com





More information about the use-livecode mailing list