Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

99miles

macrumors member
Original poster
Oct 10, 2008
50
0
I have a situation where you hold your finger and drag to move a view. If you touch another finger and drag while the first one is still down, the view follows that new touch. Is there a simple way to block the second touch down/move when there's already a finger down?
This is kind of an edge case, but i'd like to fix it.
Thanks.
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
I suspect that you'll need to process both touches and determine which is the original and which is the new. Then, just ignore the new one.
 

99miles

macrumors member
Original poster
Oct 10, 2008
50
0
No, it's a different location, but since I'm trying to block this second touch in touchesMoved I can't exactly compare it to the previous location.
I guess if i were only using touchesBegan I could compare to the previous location, but again, it's in touchesMoved.

thanks
 

kalimba

macrumors regular
Jun 10, 2008
102
0
Supposedly, the UITouch objects remain constant for the duration of each touch-move-untouch sequence, so you could keep track of which touch is which by looking at those.
 

99miles

macrumors member
Original poster
Oct 10, 2008
50
0
Thanks guys, I finally got it.

I'm not sure why, but for some reason the touches NSSet passed into the touchesMoved method only had one touch even when there were two. In the end was able to determine if there were multiple touches happening by getting it through the UIEvent:

NSSet *numTouches = [event allTouches];

Since I'm not too concerned about this edge case, but just wanted to make the apps' response to it a little prettier just in case, I just bounce out of touchesMoved if i detect multiple touches:

if( [numTouches count] > 1 )
return;

There's undoubtedly a better way, but this works for my purposes.
Thanks again!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.