views:

362

answers:

1

I'm using TouchesBegan TouchesMoved with Multitouch.

I have a manual implementation of what is essentially a button.

I bounds test on the point of TouchesBegan to set the button as down and the same for TouchesEnded to reset it.

The problem is if the user moves the finger out of the bounds of the button before lifting then the TouchesEnded is outside of the bounds of the button where the touch started.

I can't just reset everything on touchesended as the user might still be holding another button down with another finger.

What is the recommended solution to this? UIButton must be doing something similar somehow.

+2  A: 

You need to watch touchesMoved: and "deactivate" your button when the touch moves outside of its bounds, and "reactivate" your button when the touch moves back in. See Handling a Complex Multi-Touch Sequences for explanation of how to watch for mutations on a multi-touch sequence (fancy way of saying "which finger was that?")

Rob Napier
ahh thanks that's what i was looking for. So they use a dictionary to hold the touch information.
PeanutPower