iOS - picking from a scrolling list

Thomas McGrath III mcgrath3 at mac.com
Thu Apr 5 09:44:43 EDT 2012


Graham,

I don't use mobgui but instead I use tmControl for layout of iOS elements.  There are two types of scrolling lists possible in LC. The first is using mobilePick by itself or use an option button (that uses the iOS mobilePicker). The second is using either an LC field object or other objects like the list field in tmControl but either of these needs to be in a group and the group can now have an iOS scroller applied to it.

If you create a field that is very long and group it then select the group and make it shorter than that field it will scroll. I can't remember if the group needs locked or not. There are a couple of glitches to watch out for.

Here is parts of a script that controls a grouped field and an iOS scroller. A mouseUp in the field can return the desired line etc.

local sScrollerId
on scrollerDidScroll pOffsetX, pOffsetY
    lock screen
    set the hScroll of group "InputScrollerGroup" to pOffsetX
    set the vScroll of group "InputScrollerGroup" to pOffsetY
    unlock screen
end scrollerDidScroll

on openCard
    set the layerMode of group "InputScrollerGroup" of this card to "scrolling"
    
    set the unboundedHScroll of group "InputScrollerGroup" to true
    set the unboundedVScroll of group "InputScrollerGroup" to true
    
     -- add items to a field "Counter" and have it grow to fit the contents
    set the height of field "Counter" of this card to the formattedHeight of field "Counter"
    set the top of field "Counter" to the top of group "InputScrollerGroup"
  
    set the threeDHilite of field "Lap Counter" to false
    iphoneControlCreate "scroller", "InputScroller"
    put the result into sScrollerId
    put the rect of group "InputScrollerGroup" into tRect
    iphoneControlSet sScrollerId, "rect", tRect
    put the formattedHeight of field "Counter" into tHeight
    iphoneControlSet sScrollerId, "contentRect", (0, 0, 0, tHeight)
    iphoneControlSet sScrollerId, "indicatorInsets", (0,0,6,0)
    iphoneControlSet sScrollerId, "visible", "true"
    iphoneControlSet sScrollerId, "canBounce", true
    
    iphoneControlSet sScrollerId, "declerationRate", fast
    iphoneControlSet sScrollerId, "scrollingEnabled", true
    iphoneControlSet sScrollerId, "canScrollToTop", true 
    iphoneControlSet sScrollerId, "delayTouches", true
    
    iphoneControlSet sScrollerId, "vscroll", 0
    set the vScroll of group "InputScrollerGroup" to 0
    set the vScroll of field "Counter" to 0
    
    focus on nothing
    iphoneControlDo sScrollerId, "flashScrollIndicators"
end openCard

on closeCard
    iphoneControlDelete "InputScrollerGroup"
end closeCard

-- Tom McGrath III
http://lazyriver.on-rev.com
3mcgrath at comcast.net

On Apr 4, 2012, at 12:31 PM, Graham Samuel wrote:

> In an iOS app I'm developing I would like to use a scrolling text list where the user can drag the whole list up and down (i.e. scroll the list) but can also select a line by touching it.  This type of interaction is permitted in iOS: a simple example is the index of Apple's own Contacts app.
> 
> I have looked at the latest iOS notes for LC5.5 (Scroller Control - UIScrollView) and I can't understand how the textual list (like an ordinary LC scrolling field) would come in to the scroller; I'm also just beginning to use MobGUI to introduce some native controls, and that has a scroller object too. It is  complex and consists of a group into which it is possible to introduce such an LC field, but in that case it is sensitive to touches, but not to dragging/scrolling - I tried setting the parameter 'delay touches' but it didn't seem to change anything. 
> 
> Obviously I have missed some underlying concept here. The LC iOS doc says that a scroller isn't a container for other controls, but I don't know what that means. It seems a gnomic pronouncement rather on the lines of "Light is not a thing" or “Die Welt ist alles, was der Fall ist.” Sounds terrific, but what does it actually mean?
> 
> I also tried reading the UIScrollView section of Apple's documentation. It's promising in a way (it mentions the need to do the kind of thing I'm talking about) but it doesn't help me enough to allow me to proceed.
> 
> Does anyone know how to do this? I have asked MobGUI support, but I don't know how reactive they are.
> 
> TIA
> 
> Graham
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list