0

I subclassed the UIWindow, but for some reason the - (void)sendEvent:(UIEvent *)event gets called 2 times for any interaction with the screen. Any ideas why would that happen?

Zsolt
  • 3,648
  • 3
  • 32
  • 47
  • Well, what events are being sent? That information would be useful...I imagine the names are touchesBegan and touchesMoved. – borrrden May 14 '12 at 06:09
  • well I touch the screen. from what I understand sendEvent/UIWindow is at the root of the responder chain. before any other view can get this event into the touchesBegan method of it's own, the view is found by the UIWindow hitTest method. so my touch generates 2 sendEvents.. both find the view.. but I don't understand why I have 2 events generated by a simple touch. – Zsolt May 15 '12 at 12:16
  • Log the names of the events in the method, that should help you get more info. – borrrden May 15 '12 at 13:31

2 Answers2

2

For debugging purposes, subclass window (of app delegate) and override sendEvent: method

-(void) sendEvent:(UIEvent *)event
{
    NSLog(@"%@",event);
    [super sendEvent:event];
}

Most probably, you will notice the events responsible for TouchesBegan and TouchesEnded (for tapping). This can be tested by subclassing the View and overriding touch related methods.

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@"tocuhesBegan");
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@"touchesMoved");
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@"touchesEnded");
}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@"touchesCancelled");
}

Also, try drag/swipe on the view to notice the change in count of events sent to view :)

Tatvamasi
  • 2,537
  • 19
  • 14
0

sendEvent gets called for fingerDown and allFingersUp

Yuriy Gettya
  • 693
  • 10
  • 20