bzr branch
/browse/iphone/tappity
| Line | Revision | Contents |
| 1 | 46 | // |
| 2 | // TappityView.m |
|
| 3 | // tappity |
|
| 4 | // |
|
| 5 | // Created by döme on 25.10.2009. |
|
| 6 | // Copyright 2009 __MyCompanyName__. All rights reserved. |
|
| 7 | // |
|
| 8 | ||
| 9 | #import "TappityView.h" |
|
| 10 | #import "TappityClient.h" |
|
| 11 | #import "Tappity.h" |
|
| 12 | ||
| 13 | ||
| 14 | @implementation TappityView |
|
| 15 | ||
| 16 | ||
| 17 | - (id)initWithFrame:(CGRect)frame |
|
| 18 | { |
|
| 19 | if ((self = [super initWithFrame: frame])) |
|
| 20 | { |
|
| 21 | // Initialization code |
|
| 22 | } |
|
| 23 | return self; |
|
| 24 | } |
|
| 25 | ||
| 26 | ||
| 27 | - (void)drawRect:(CGRect)rect { |
|
| 28 | // Drawing code |
|
| 29 | } |
|
| 30 | ||
| 31 | ||
| 32 | - (void)dealloc |
|
| 33 | { |
|
| 34 | self.tapClient = nil; |
|
| 35 | [super dealloc]; |
|
| 36 | } |
|
| 37 | ||
| 38 | - (NSArray*) touchesAsPlist: (NSSet*) touches |
|
| 39 | { |
|
| 40 | NSMutableArray* ary = [NSMutableArray array]; |
|
| 41 | for (UITouch* touch in touches) |
|
| 42 | { |
|
| 43 | NSMutableDictionary* dict = [NSMutableDictionary dictionary]; |
|
| 44 | [dict setObject: [NSNumber numberWithInteger: (NSInteger)touch] forKey: @"touchIdentifier"]; |
|
| 45 | [dict setObject: [NSNumber numberWithInteger: [touch phase]] forKey: @"touchPhase"]; |
|
| 46 | [dict setObject: [NSNumber numberWithInteger: [touch tapCount]] forKey: @"touchTapCount"]; |
|
| 47 | [dict setObject: [NSNumber numberWithFloat: [touch locationInView: self].x] forKey: @"touchX"]; |
|
| 48 | [dict setObject: [NSNumber numberWithFloat: [touch locationInView: self].x] forKey: @"touchY"]; |
|
| 49 | [dict setObject: [NSNumber numberWithFloat: [touch previousLocationInView: self].x] forKey: @"touchPX"]; |
|
| 50 | [dict setObject: [NSNumber numberWithFloat: [touch previousLocationInView: self].x] forKey: @"touchPY"]; |
|
| 51 | |
|
| 52 | [ary addObject: dict]; |
|
| 53 | } |
|
| 54 | return ary; |
|
| 55 | } |
|
| 56 | ||
| 57 | - (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event |
|
| 58 | { |
|
| 59 | NSLog(@"touchesBegan"); |
|
| 60 | _printGSEvent(event); |
|
| 61 | ||
| 62 | [tapClient sendTouch: event inPhase: UITouchPhaseBegan]; |
|
| 63 | } |
|
| 64 | ||
| 65 | - (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event |
|
| 66 | { |
|
| 67 | NSLog(@"touchesEnded"); |
|
| 68 | _printGSEvent(event); |
|
| 69 | ||
| 70 | [tapClient sendTouch: event inPhase: UITouchPhaseEnded]; |
|
| 71 | } |
|
| 72 | ||
| 73 | - (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event |
|
| 74 | { |
|
| 75 | NSLog(@"touchesMoved"); |
|
| 76 | _printGSEvent(event); |
|
| 77 | ||
| 78 | [tapClient sendTouch: event inPhase: UITouchPhaseMoved]; |
|
| 79 | } |
|
| 80 | ||
| 81 | - (void) touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event |
|
| 82 | { |
|
| 83 | NSLog(@"touchesCancelled"); |
|
| 84 | _printGSEvent(event); |
|
| 85 | ||
| 86 | [tapClient sendTouch: event inPhase: UITouchPhaseCancelled]; |
|
| 87 | } |
|
| 88 | ||
| 89 | ||
| 90 | @synthesize tapClient; |
|
| 91 | ||
| 92 | @end |
Loggerhead 1.17 is a web-based interface for Bazaar branches