No move/ended event for a touch listener of an object in a scrollView

I created an object 

local obj = newCircle(...)

and insert it into a scrollView

scrollView:insert(obj)

and I create a touch listener for the object

obj:addEventListener("touch", objTouchListener)

In most cases, there is no problem for objTouchListener to receive all the event phases (began, move, ended)

However, there is one case, there is only began event and there is no subsequent move/ended events… here is how to reproduce it:

(1) swipe the finger on the scrollView

(2) lift finger

(3) the scrollView is still scrolling with its own momentum even though the finger is off the screen

(4) tap the object

Usually the tap in step (4) will generate began & ended events, which is good. But if you try a few times, you will see sometimes there is a began event for the tap but there is no ended event following.

Is this a bug?

I see this happening because I added some effect when user pressed the object in step (4), and waiting for the ended event to remove the effect. Now without the ended event, the effect is still there and I have no way to remove the effect if the ended event is missing.

Update: when the problem happens, there is actually moved event but no ended event.

Updated: after more testing, even without scrolling, by just clicking on the object, sometimes there is just no ended event, so weird…  :o

Here is the object listener code

local function channelTouchListener(event) if event.phase == "began" then print("channelTouchListener began") elseif event.phase == "moved" then local dx = math.abs( event.x - event.xStart ) local dy = math.abs( event.y - event.yStart ) print("channelTouchListener moved, dx/dy=", dx, dy) else print("channelTouchListener =\> other event: ", event.phase) end return true end

And here is the console output when the problem happens

2013-12-07 20:50:23.482 Corona Simulator[4671:507] channelTouchListener began 2013-12-07 20:50:23.488 Corona Simulator[4671:507] channelTouchListener moved, dx/dy= 1 0 2013-12-07 20:50:23.528 Corona Simulator[4671:507] channelTouchListener moved, dx/dy= 1 1 2013-12-07 20:50:23.547 Corona Simulator[4671:507] channelTouchListener moved, dx/dy= 2 6

At this point, my mouse click is already released, but you can see clearly that there is no following “ended” or any other event.

This also happens in iOS device.

(I have not tested it on Android device yet).

I added print in scrollView listener, and when the problem happened, the console log showed 

2013-12-07 21:31:43.179 Corona Simulator[4774:507] channelTouchListener began 2013-12-07 21:31:43.191 Corona Simulator[4774:507] channelTouchListener moved, dx/dy=        4    0 2013-12-07 21:31:43.208 Corona Simulator[4774:507] channelTouchListener moved, dx/dy=        5    1 2013-12-07 21:31:43.225 Corona Simulator[4774:507] scrollListener, event phase =     moved 2013-12-07 21:31:43.242 Corona Simulator[4774:507] scrollListener, event phase =     moved 2013-12-07 21:31:43.260 Corona Simulator[4774:507] scrollListener, event phase =     moved 2013-12-07 21:31:43.274 Corona Simulator[4774:507] scrollListener, event phase =     ended 2013-12-07 21:31:44.180 Corona Simulator[4774:507] scrollListener, event phase =     nil

I found the answer for my problem.

I should use setFocus(), otherwise when the object is out of bound, I was expecting an ended event here, however scrollView takes care of the scrolling automatically, so there is no ended event in this case.

Update: when the problem happens, there is actually moved event but no ended event.

Updated: after more testing, even without scrolling, by just clicking on the object, sometimes there is just no ended event, so weird…  :o

Here is the object listener code

local function channelTouchListener(event) if event.phase == "began" then print("channelTouchListener began") elseif event.phase == "moved" then local dx = math.abs( event.x - event.xStart ) local dy = math.abs( event.y - event.yStart ) print("channelTouchListener moved, dx/dy=", dx, dy) else print("channelTouchListener =\> other event: ", event.phase) end return true end

And here is the console output when the problem happens

2013-12-07 20:50:23.482 Corona Simulator[4671:507] channelTouchListener began 2013-12-07 20:50:23.488 Corona Simulator[4671:507] channelTouchListener moved, dx/dy= 1 0 2013-12-07 20:50:23.528 Corona Simulator[4671:507] channelTouchListener moved, dx/dy= 1 1 2013-12-07 20:50:23.547 Corona Simulator[4671:507] channelTouchListener moved, dx/dy= 2 6

At this point, my mouse click is already released, but you can see clearly that there is no following “ended” or any other event.

This also happens in iOS device.

(I have not tested it on Android device yet).

I added print in scrollView listener, and when the problem happened, the console log showed 

2013-12-07 21:31:43.179 Corona Simulator[4774:507] channelTouchListener began 2013-12-07 21:31:43.191 Corona Simulator[4774:507] channelTouchListener moved, dx/dy=        4    0 2013-12-07 21:31:43.208 Corona Simulator[4774:507] channelTouchListener moved, dx/dy=        5    1 2013-12-07 21:31:43.225 Corona Simulator[4774:507] scrollListener, event phase =     moved 2013-12-07 21:31:43.242 Corona Simulator[4774:507] scrollListener, event phase =     moved 2013-12-07 21:31:43.260 Corona Simulator[4774:507] scrollListener, event phase =     moved 2013-12-07 21:31:43.274 Corona Simulator[4774:507] scrollListener, event phase =     ended 2013-12-07 21:31:44.180 Corona Simulator[4774:507] scrollListener, event phase =     nil

I found the answer for my problem.

I should use setFocus(), otherwise when the object is out of bound, I was expecting an ended event here, however scrollView takes care of the scrolling automatically, so there is no ended event in this case.