tags:

views:

316

answers:

2

I'm looking for a way to get all the current touches even if no event has occurred. I know about [UIEvent allTouches] but I need to be able to see "these are all the touches on the screen" even if none of them has changed. It seems like it should be possible because allTouches can access touches which haven't been updated, so the phone is tracking them.

A: 

Try hitTest:withEvent and filter with pointInside:withEvent.

David Sowsy
hitTest will tell me which view a point is in. I want a set of all the touches on the screen. Unless I've misunderstood something.
David Kanarek
I generally hitTest with pointInside to determine the coordinates the user touches on the top most view when a component is being finicky in the responder chain (like with nested scrollviews, custom GUI widgets, etc) The [UIEvent allTouches] returns an array of all the touches (UITouch) the API wants available to you. What you want is access to the internal state of the last system UITouch? I think the best you will be able to do is access touchesBegan and touchesEnded, and cache a UITouch compare them yourself.
David Sowsy
Yeah, I was afraid I'd have to do it myself, just seems silly they don't open it up to you.
David Kanarek
Seems the best thing to do is cache the points as you said. If you want to add that as an answer, I'll accept it.
David Kanarek
A: 

Override touchesBegan and touchesEnded, and compare the current point against the cached point from the event.

David Sowsy
Note that I had no current point to compare with. I simply used `touchesBegan/Moved/Ended` to maintain a cache of touch locations and referred to that when necessary.
David Kanarek