Re: forwarding Touch Events
Re: forwarding Touch Events
- Subject: Re: forwarding Touch Events
- From: Luke the Hiesterman <email@hidden>
- Date: Wed, 1 Dec 2010 12:19:13 -0800
It sounds like you might be best off doing your touch handling all in the superview. You can marshal all your subviews the way you want from there. There shouldn't be any reason to call touch handling methods yourself.
Luke
On Dec 1, 2010, at 12:06 PM, Gustavo Pizano wrote:
> Hello all.
>
> in my iPad app I have a superview screen size and there im placing smaller subviews, when I touch one of those I need to place on top another custom view which draw a circle around the taped subview, so the subview is exactly in the middle of the circle which is drawn in that view on top of it so give a fell of selections, + another functionality I need to do with that circle, like rotate the subview i tapped. Anyway, now ,if I tap somewhere between the edge of the circle and the beginning of the view bellow, I remove the circle's view but then I need to have the view bellow with the touch I did before in order to move it..
>
> Now the symptoms are : I touch in the described area, the circles view disappears, but I can't move the view bellow the touch I initiated on the circle's view, I need to lift the finger and then I can move the view I touch.
>
> I tried subclassing UIWindow and overwritting sendEvent method, checking if I have a subview under the touch to call that views touches methods and then call [super send:event ]. but for a touch began I get the touch, but again for moving I get nothing.
>
> this is what I did there:
>
> NSSet *touches = [event allTouches];
> NSLog(@"size of set %i",[touches count]);
> UITouch * aTouch = [touches anyObject];
> UIView * viewUnderPoint;
> CGPoint p = [aTouch locationInView:itemsView];
> if((viewUnderPoint = [itemsView hitTest:p withEvent:event])){
> NSLog(@"Found a view under %@",[[viewUnderPoint class] description]);
>
> NSMutableSet *began = nil;
> NSMutableSet *moved = nil;
> NSMutableSet *ended = nil;
> NSMutableSet *cancelled = nil;
>
> for(UITouch *touch in touches) {
> switch ([touch phase]) {
> case UITouchPhaseBegan:
> if (!began) began = [NSMutableSet set];
> [began addObject:touch];
> break;
> case UITouchPhaseMoved:
> if (!moved) moved = [NSMutableSet set];
> [moved addObject:touch];
> break;
> case UITouchPhaseEnded:
> if (!ended) ended = [NSMutableSet set];
> [ended addObject:touch];
> break;
> case UITouchPhaseCancelled:
> if (!cancelled) cancelled = [NSMutableSet set];
> [cancelled addObject:touch];
> break;
> default:
> break;
> }
> }
> // call our methods to handle the touches
> if (began) [viewUnderPoint touchesBegan:began withEvent:event];
> if (moved) [viewUnderPoint touchesMoved:moved withEvent:event];
> if (ended) [viewUnderPoint touchesEnded:ended withEvent:event];
> if (cancelled) [viewUnderPoint touchesCancelled:cancelled withEvent:event];
> }
>
> based on the docs,
> so I dunno if there is a way to get a view which is under another one on top, receive the touches I did on that top most view.
>
> Any ideas?
>
> Thx
> Gustavo
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden