iOS Scrolling: Setting the scroll values

Mark Schonewille m.schonewille at economy-x-talk.com
Sun Jan 22 07:20:17 EST 2012


Hi Charles,

Since the iPhone scroller is invisible, you can always set the hScroll and the vScroll to 0 whenever your card opens. Use the regular LiveCode properties to reset the scroll values and positions of your objects whenever your card opens. If you set both the scroll of the iPhone object and the LiveCode controls to 0, you're sure that everything matches. Now you can catch the scrollerDidScroll message.

After resetting positions and scroll values, all you do is changing the scrolls of groups and iPhone scrollers: 

set the hscroll of grp x to 20
iPhoneControlSet sScrollerID,"hScroll",20

Btw you need to make sure that the dimensions of the iPhoneConrol's rect are equal to the formattedHeight and formattedWidth of the group or field that you're trying to scroll.

If you want to scroll your marker horizontally, you could use transparent picture that's twice as wide as the screen, group it and then set the width of the group to the width of your screen. Now you can set the hScroll to half the formattedWidth to center the picture. It is probably easiest if you set the margins of the group(s) to 0.

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
KvK: 50277553

Download the Installer Maker Plugin 1.7 for LiveCode here http://qery.us/za

On 22 jan 2012, at 03:03, Charles E Buchwald wrote:

> Hi List,
> I'm having a hard time figuring out how to set the scroll of an iOS scroller.
> I have big image "Map" and a 20 x 20 graphic named "Marker" in the scrolling group.
> I'd like to set the scrolling of the such that "Marker" is centered in the window when the card opens.
> So I thought to do it like this....
> 
> global sScrollerId
> on scrollToLocation
>   iphoneControlSet sScrollerId, "hScroll", 0	
>   put the left of grc "Marker" - (the width of this stack / 2) - (the width of grc "Marker" / 2) into tNewHScroll
>   iphoneControlSet sScrollerId, "hScroll", tNewHScroll
> end scrollToLocation
> 
> I put this in a button script to test it, and repeated button presses toggle between 2 different scroll values, one of which is correct.
> If I put it in an openCard handler, sometimes it works and sometimes it doesn't.
> 
> Any idea what I am missing?
> 
> Thanks,
> - Charles
> 
> --
> Charles E. Buchwald
> http://buchwald.ca





More information about the use-livecode mailing list