Touch event error on Android

Hi everybody

I have an app without multitouch, and it works perfectly on the simulator as well as on iOS devices, but I have some problems with the touch events on Android devices. The problem is the following:

  1. You put a finger on the screen and hold it there
  2. While the first finger is still on the screen, you put another finger on it.

The second finger will not make any events to be fired, which makes sense, since I’m not using multitouch, but I also loose the original touch, without any ‘ended’ or ‘cancelled’ event is fired.

Am I forced to write my own event-manager to handle such situations?

Thanks for your help.

/Magnus [import]uid: 107812 topic_id: 30792 reply_id: 330792[/import]

The behavior sounds like what happens when you touch an object and then move your finger off of it. I imagine that’s essentially what the device thinks you are doing.

I believe you can use setFocus function to take care of this.

http://docs.coronalabs.com/api/type/StageObject/setFocus.html [import]uid: 147305 topic_id: 30792 reply_id: 123253[/import]

You might be right. Maybe it’s me who don’t really understand setFocus. I guess when I use object:setFocus all touch events will go through that object first. Will the event still be propagated to other objects on the stage?

I have already played around with setFocus, but I might give it another shot. [import]uid: 107812 topic_id: 30792 reply_id: 123256[/import]

Once an object has focus it owns touch events. Touch will not be propagated to other objects/runtime events. That being the case you generally need to make sure you set your setFocus to nil on your ‘ended’ event.

[import]uid: 147305 topic_id: 30792 reply_id: 123257[/import]

Thanks for the clarification, budershank.

I just tested the bug using setFocus. It is still the same. I drag an object around, setting setFocus on the object, put a second finger on the screen, lift both of them, and “ended” event is never fired on any of the touches. When I touch the screen again, the object is still in focus, as expected.

It only happens on Android, so it might be a bug. [import]uid: 107812 topic_id: 30792 reply_id: 123258[/import]

Interesting, doesn’t sound like expected behavior so maybe it is. [import]uid: 147305 topic_id: 30792 reply_id: 123259[/import]

This is a bug in the standard examples, such as SlideVidew. CoronaLab what to do? When the bug will is fixed? [import]uid: 138593 topic_id: 30792 reply_id: 123261[/import]

That’s true. I found the bug in the DragMe example. [import]uid: 107812 topic_id: 30792 reply_id: 123301[/import]

The behavior sounds like what happens when you touch an object and then move your finger off of it. I imagine that’s essentially what the device thinks you are doing.

I believe you can use setFocus function to take care of this.

http://docs.coronalabs.com/api/type/StageObject/setFocus.html [import]uid: 147305 topic_id: 30792 reply_id: 123253[/import]

You might be right. Maybe it’s me who don’t really understand setFocus. I guess when I use object:setFocus all touch events will go through that object first. Will the event still be propagated to other objects on the stage?

I have already played around with setFocus, but I might give it another shot. [import]uid: 107812 topic_id: 30792 reply_id: 123256[/import]

Once an object has focus it owns touch events. Touch will not be propagated to other objects/runtime events. That being the case you generally need to make sure you set your setFocus to nil on your ‘ended’ event.

[import]uid: 147305 topic_id: 30792 reply_id: 123257[/import]

Thanks for the clarification, budershank.

I just tested the bug using setFocus. It is still the same. I drag an object around, setting setFocus on the object, put a second finger on the screen, lift both of them, and “ended” event is never fired on any of the touches. When I touch the screen again, the object is still in focus, as expected.

It only happens on Android, so it might be a bug. [import]uid: 107812 topic_id: 30792 reply_id: 123258[/import]

Interesting, doesn’t sound like expected behavior so maybe it is. [import]uid: 147305 topic_id: 30792 reply_id: 123259[/import]

This is a bug in the standard examples, such as SlideVidew. CoronaLab what to do? When the bug will is fixed? [import]uid: 138593 topic_id: 30792 reply_id: 123261[/import]

That’s true. I found the bug in the DragMe example. [import]uid: 107812 topic_id: 30792 reply_id: 123301[/import]