Setting mobile scroller hScroll fails
monte at appisle.net
Wed May 29 19:22:40 EDT 2019
> On 30 May 2019, at 5:01 am, J. Landman Gay via use-livecode <use-livecode at lists.runrev.com> wrote:
> Thanks Monte, I did over-summarize. I'm not sure why it's going wrong, but it sounds like it's something I'm doing. I have a standard "createScroller" handler that I've been using for years, but I've never had to set the hScroll before. It's always been zero.
> In this case, I set the hScroll of the group to the formattedWidth of the group, which may be wrong.
The max scroll will be the formattedWidth of the group - the width of the group unless you have unboundedHScroll true. I _think_ if it’s false then the engine will automagically clamp that though.
> The engine seems to compensate though and sets the scroll as far as it should go. Then I call "createScroller" and pass the name of the group. The handler:
> command createScroller pName
> -- pName = the long ID of a grp
> put the rect of control pName into tRect
> put the hScrollBar of control pName into tHScroller
> put the vScrollBar of control pName into tVScroller
> put the hScroll of control pName into tHScroll
> put the vScroll of control pName into tVScroll
> set the hScrollBar of control pName to false -- remove fld scrollbars on mobile
> set the vScrollBar of control pName to false
> mobileControlCreate "scroller", pName
> mobileControlSet pName, "rect", tRect
> put ("0,0," & (the formattedwidth of control pName) & "," & the formattedheight of control pName) into tContentRect
> mobileControlSet pName, "contentRect", tContentRect
> mobileControlSet pName, "hScroll", 0
> mobileControlSet pName, "vScroll", 0
> mobileControlSet pName, "hIndicator", tHScroller
> mobileControlSet pName, "vIndicator", tVScroller
> mobileControlSet pName, "hScroll", tHScroll
> mobileControlSet pName, "vScroll", tVScroll
> mobileControlSet pName, "visible", true
> end createScroller
> I initialize both the group and the scroller to 0 before doing anything else, because when I wrote it I couldn't get them to align correctly otherwise. I should also probably mention that I'm using fullscreenMode "showAll" and the group is expanded beyond the borders of the card to fill the screen; i.e., it probably has a negative left margin and a wider right margin.
> When the scroller finally does scroll (after resetting itself) it scrolls too far at the left side by the number of pixels between the screen left and the card left, and cuts off the same amount on the right side.
> Can you see what I should change?
I’m really not sure at this stage. Have you tried logging the x,y values you get in scrollerDidScroll? This may need a simple stack to reproduce it and an email to support so we can figure out what’s up.
More information about the use-livecode