Catching scroller Messages

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
FireWorx
Posts: 362
Joined: Wed Sep 07, 2011 9:39 pm

Catching scroller Messages

Post by FireWorx » Thu Mar 15, 2012 8:00 pm

Hi,
My ultimate goal is to be able to establish if a user "bounces" off either the side margins or top margins of a scroller or browser in IOS. I have an application that loads PDf's maps into a browser. The maps are indexed on a grid system. If the user pans hard to say the right I would like to load the page that exists on the grid to the right. Same for top, bottom and both sides.

I already have the navigation script worked out but need to "catch the message" if there is one to execute the page load

It looks like the scroller returns more messages than the browser which is primarily regarding the status of a page load. So I loaded the browser into a scroller to see what I can do. I inserted the following code into the same card script that the scroller creation handler resides on to investigate but got no response back while scrolling around.

What am I doing wrong and do any of you think what I am trying to do is possible?

on scrollerBeginDecelerate
answer "deacelerating now"
end scrollerBeginDecelerate
##This message is sent when scrolling is about to start decelerating.

on scrollerEndDecelerate
answer "stopped deacelerating"
end scrollerEndDecelerate
##This message is sent when scrolling has finished decelerating.

on scrollerScrollToTop
answer "just scrolled to top"
end scrollerScrollToTop
##This message is sent when the scroller is scrolled to top by touching the status bar.

on scrollerBeginDrag
answer "begining a drag"
end scrollerBeginDrag
##This message is sent when a scroll initiating drag is started.

on scrollerEndDrag didDecelerate
answer "drag is finished"
end scrollerEndDrag

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Catching scroller Messages

Post by Dixie » Thu Mar 15, 2012 8:30 pm

Hi...

Yes it is possible ... I would use the scrollerDidScroll message. it responds quickly, then catch the horizontal & vertical offsets... You will know how large your .pdf's are so you can work out how far they are able to scroll, if they are pushed harder on the horizontal or vertical plane and the values are greater or less than they should be then load another of your maps..

Something like...

Code: Select all

on scrollerDidScroll hOffset, vOffset
   if  vOffset > Y  OR vOffset < Y then ...
   if  hOffset > X  OR hOffset < X then ...
end scrollerDidScroll
be well

Dixie

FireWorx
Posts: 362
Joined: Wed Sep 07, 2011 9:39 pm

Re: Catching scroller Messages

Post by FireWorx » Thu Mar 15, 2012 10:12 pm

Thanks for your quick reply! I will give it a spin.
Thanks again!
Dave

FireWorx
Posts: 362
Joined: Wed Sep 07, 2011 9:39 pm

Re: Catching scroller Messages

Post by FireWorx » Fri Mar 16, 2012 12:37 am

Thanks Dixie,
I did get the code you offered up to work in the scroller example I found here from Bernard titled lcMobileScroll_0.0.3. However I attempted to get it to work on the attached sample stack Gerry uploaded with no luck. Now Gerry's stack was much nicer before I broke into it and I started frankensteining the code so I hope he doesn't mind me re uploading it. It was a real benefit to me. Thanks Gerry!

It loads html into a browser and then loads the browser group into a scroller. I don't understand it all but it does allows me to use href linked buttons within the scroller which is what I wanted and since I am not up to speed on data grids...

Since I am thinking of placing the browser I use to view the map PDF's in one of my other projects inside a scroller in order to catch the scroll message to navigate by directionally I thought I would grab this example and test it first. I placed the code you gave me in every group, card, and stack with nothing.

Have you got it to work in your project? Is there something obvious that is blocking the message?

Thanks,
Dave
Attachments
htmlscroller-1.livecode.zip
(43.58 KiB) Downloaded 202 times

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4178
Joined: Sun Jan 07, 2007 9:12 pm

Re: Catching scroller Messages

Post by bn » Sun Mar 18, 2012 6:14 pm

Hi Dave,

the problem I see is that you create a browser but you want to have the messaging of a scroller.

As far as I see a browser does not return x,y coordinates and all other messages related to positon etc. So there is not way to tell when the browser comes to the bounding sides of the object.

That is the reason why you don't get a scollerDidScroll message.

I am a little puzzled that the browser object you create and for which you set a lot of scroller properties does not throw an error.

Maybe one could put a browser into a scroller and you scroll the browser instead of the browser scrolling your PDF. The browser would have the autofit "false" and the size of the browser would be the size of the PDF, but then you would not have the pinch/zoom of the browser. The scroller would "eat" your touches. And I don't see a way to pass the pinch to the browser object. (I did not actually try this)

Right now I don't see a solution to your plan to go from one PDF to the next when the user scrolls to the border of a PDF.

Kind regards

Bernd
Maybe someone has an idea.

Post Reply