newScrollView: eventX, eventY?

Hi,

Newbie to corona here. For my first exercise, I am building an (endlessly) vertical scrolling wall of images like Pinterest. You can flick to scroll up and down but when you touch an image it zooms in on that image.

Although I could create individual listeners for every image I put in the newScrollView, that seems pretty inefficient and I’m worried it could perform poorly on the device and eat memory.

If I know the bounds of every image in the scrolling wall, I could watch for touches on the newScrollView and see if the coordinates are within an image and didn’t move.

However, I can’t seem to get event.x from the touch event I get from newScrollView.

Specifically, I have code like this:

local function printTouch2( event, where )  
 print ("x=" .. event.x)  
end  
  
local function onTouch3(event)  
 if event.type == "beganScroll" then  
 printTouch2(event,"beganScroll")  
 elseif event.type == "endedScroll" then  
 printTouch2(event,"endScroll")  
 end  
end  
  
-- Setup a scrollable content group  
local scroller = widget.newScrollView { width=display.contentWidth, height=display.contentHeight, listener = onTouch3 }  

Can anybody tell me how to find where the touch in a scrollview happened (both up and down so I can tell if it moved)?

Thank you very much.
[import]uid: 155483 topic_id: 27900 reply_id: 327900[/import]

After running my program in the debugger, I found only these properties for the newScrollView event:

event(table: 0x1cc2cf0) =  
{  
 target = table: 0x13354550  
 type = "endedScroll"  
 name = "scrollEvent"  
}  

and the target table has only:

  
event.target(table: 0x13354550) =  
{  
 widgetWidth = 320  
 takeFocus = function: 0x5104f40  
 removeSelf = function: 0x5105080  
 virtual = table: 0x1335bd10  
 scrollToRight = function: 0x5105060  
 cached\_insert = function: 0x13361800  
 fixed = table: 0x1335f8f0  
 getContentPosition = function: 0x5104f20  
 insert = function: 0x13376430  
 id = "widget\_scrollView"  
 widgetHeight = 480  
 scrollToLeft = function: 0x5105040  
 scrollToBottom = function: 0x5105020  
 \_class = table: 0x56691d0  
 scrollToPosition = function: 0x5104fa0  
 scrollToTop = function: 0x5105000  
 \_proxy = userdata: 0x13354544  
 cached\_removeSelf = function: 0x13356440  
 content = table: 0x13358130  
 \_isWidget = true  
}  

So I’m guessing what I want is impossible. Unless, potentially I put an overlay object over the scrollview that gets touches and returns false so that the scrollview still works for scrolling. Then I’d have to figure out the scrollPosition to calculate which images are visible relative to a non-scrolled touch position.

Any feedback appreciated with this problem… I can’t be alone with this sort of challenge? [import]uid: 155483 topic_id: 27900 reply_id: 112925[/import]

I’ve got the same problem.

I could only get the mouse x (start-position) from the eventlistener:

function scrollViewListener( event ) ex\_old = tonumber(event.x) print(ex\_old) end [import]uid: 140000 topic_id: 27900 reply_id: 122671[/import]

I’ve got the same problem.

I could only get the mouse x (start-position) from the eventlistener:

function scrollViewListener( event ) ex\_old = tonumber(event.x) print(ex\_old) end [import]uid: 140000 topic_id: 27900 reply_id: 122671[/import]