iOS - picking from a scrolling list
Howard Bornstein
bornstein at designeq.com
Sun Jul 29 17:34:33 EDT 2012
Hi Tom,
Thank you for this code. It has been very helpful in getting me going on
using an IOS scroller. It works fine except for the following situation,
which is baffling me at this point.
If I implement a scroller with your code, everything works they way I would
expect it to. However, if I scroll the list (say half-way down) and then
leave the card, when I return back, the top of the scrollable field is not
at the top of the scroller group (which I would expect because of this line
of code: set the top of field "Counter" to the top of group
"InputScrollerGroup") but is, in fact, half-way down the scroller group.
Then, if I try to scroll the field up, it never gets to the bottom of the
field, but instead "bounces" somewhere near the middle of the content. In
other words, it looks like the entire field is offset down by some amount
(probably a function of how much I had it scrolled before I left the card).
I can't figure out why this would happen since the CloseCard handler
deletes the IOS scroll group and OpenCard should create it fresh each time
I go to the card. Somehow, the field position is getting stuck after I
scroll it and then leave the card.
Do you understand why this is happening?
--
Regards,
Howard Bornstein
-----------------------
www.designeq.com
On Thu, Apr 5, 2012 at 6:44 AM, Thomas McGrath III <mcgrath3 at mac.com> wrote:
> 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
>
>
More information about the use-livecode
mailing list