Inconsistent API For stage:setFocus( obj, event.id ) ?

Hi,
I was playing around making a versatile one-class-fits-all-uses MultiTouch class, and find out that there is a very unusual behavior when applying setFocus with event.id, that is not consistent with setFocus without event.id.

So here are my conclusions (for both cases below multitouch is activated), which imply that depending on how it is used setFocus does two different things:

Case1

stage:setFocus( event.target )

If event.id is not forwarded to setFocus, event.target object will start receiving touch events from anywhere on the screen. So if we touch anywhere on screen with other fingers, all these touches will have the same event.target, which is the one we have set focus on in the code above.
This is a behavior that is quite expected, and mostly used to prevent the event “slipping out” from object (ie. we touch the object and register “began” phase but then move finger away from object: if we don’t use setFocus, we will no longer have “moved” and “ended” phases registered).

However:
Case2

stage:setFocus( event.target, event.id )

Now something completely different happens. If we forward event.id, our object will no longer be able to receive any touch event from another event.id !
After the code above is executed, if we touch the same object with other fingers (other event.id-s), the “began” event (and others) will never be fired!
This is quite awkward behavior that is no consistent with Case 1.

In Case 1, setFocus redirected any further touch event from anywhere on stage to our object “under focus”.
In Case 2, setFocus >>prevented<< any other event.id with interacting with our object.

Why is this important?
Above behavior of setFocus with event.id prevents us from using setFocus to avoid event “slipping out” of object, which I assumed was the primary function of setFocus. By slipping out I mean that if we started tracking event with an event.id for one object from “began” phase, we don’t want to lose track of the event once touch moves away from object.
With the setFocus behavior above it is not possible to “lock” event.id to a particular target and allow for other touches to be registered with the same target.

There is a multitude of simple examples of multitouch drag, etc… but none of them covers this problem. For example, if I want to be able to use pinch/zoom on more than one object at the time, I will not be able to do that, because:

  • if I don’t use setFocus(obj, event.id), I will lose track of events when they go off the objects i picked.
  • if I use setFocus(obj) without event.id, after my first touch is registered with rectangle A, all further touches will be forwarded to rectangel A, so I can’t register any touch event on rectangleB.
  • if I use setFocus(obj, event.id) on my two rectangles, I will only be able to track one finger per object, hence no zoom, pinch, slide, rotate…

Can anyone from ANSCA clarify if this is a bug or expected behavior, and if it’s the later one, how can we “lock” multiple touch event.ids to the same target ?

Thanks
N.
[import]uid: 80100 topic_id: 25467 reply_id: 325467[/import]

Bump.

Can we get a response to this issue? I am dealing with the same problem. I would like to receive and track multiple touches to one display object while still having other display objects respond to touches.

Thanks. [import]uid: 115248 topic_id: 25467 reply_id: 105205[/import]

hello there,

i too had the same issue, so i wrote my own touch manager to take care of the problem.

http://developer.anscamobile.com/code/dmc-lib-touch-manager

give it a spin and let me know if you find any issues. there is an example included in the code and more on the way.

cheers,
dmc [import]uid: 74908 topic_id: 25467 reply_id: 109939[/import]