ScrollView events: where touched?

Is there any way to tap into the touch events associated with a scrollView?

I realize that actually scrolling scrollViews is pretty much handled automagically, once set up. And I appreciate that. I also know that I can get touch events on objects that I place inside the scrollView, but what if I just want to get the position in the scroller where the user is touching when they drag to scroll the view? Would I have to make a rect that covers the entire scrollView and check for touch events? Or is the place the user touched stored in the event info somewhere already?

Sorry for the newbie question; I just don’t want to unnecessarily add another element if that information already exists somewhere (which it seems like it must for the automatic handling of the scrolling motion itself).

Hi @rzanerutledge,

Try object:contentToLocal() and object:localToContent().

Have a nice day:)
ldurniat

How do I use that in reference to the scrollView and how/when it was touched or scrolled? I get that for translations between group coordinate spaces, but I’m not sure how to get the event x/ys themselves in the first place.

Try creating a function called “scrollListener( event )” when you create your scrollView, as in https://docs.coronalabs.com/api/library/widget/newScrollView.html

What you are looking for should be inside the return “event” table when you touch and scroll and etc, like “event.x”, “event.y” and many other info and states on the scrollView.

Cool. The event.x / event.y for “began” seems to be the onscreen location for the touch event. Simple matter to calculate where on the scroller that corresponds to. Thanks for the help!

(Strangely had a hard time finding reference to all of the available event parameters in the documentation. I guess maybe because it’s different for different types of events.)