Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit c3c5c41

Browse files
committed
Merge pull request #342 from chinmaygarde/master
Avoid cancelling touches on views on gesture recognition on iOS
2 parents 25fcb18 + 9df6383 commit c3c5c41

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

sky/shell/ios/sky_surface.mm

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,9 @@
2626
// with the same coordinates
2727
return sky::EVENT_TYPE_POINTER_MOVE;
2828
case UITouchPhaseEnded:
29-
case UITouchPhaseCancelled:
30-
// We treat all cancels for raw touches as ups.
31-
// All pointers hit UITouchPhaseCancelled as soon as a
32-
// gesture is recognized.
3329
return sky::EVENT_TYPE_POINTER_UP;
30+
case UITouchPhaseCancelled:
31+
return sky::EVENT_TYPE_POINTER_CANCEL;
3432
}
3533

3634
return sky::EVENT_TYPE_UNKNOWN;
@@ -179,6 +177,10 @@ - (void)dispatchTouches:(NSSet*)touches phase:(UITouchPhase)phase {
179177
input->pointer_data = sky::PointerData::New();
180178
input->pointer_data->kind = sky::POINTER_KIND_TOUCH;
181179

180+
#define LOWER_32(x) (*((int32_t *) &x))
181+
input->pointer_data->pointer = LOWER_32(touch);
182+
#undef LOWER_32
183+
182184
CGPoint windowCoordinates = [touch locationInView:nil];
183185

184186
input->pointer_data->x = windowCoordinates.x * scale;
@@ -212,6 +214,7 @@ -(void) installGestureRecognizers {
212214
// GESTURE_FLING_START
213215
UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc]
214216
initWithTarget:self action:@selector(onFling:)];
217+
swipe.cancelsTouchesInView = NO;
215218
[self addGestureRecognizer: swipe];
216219
[swipe release];
217220

@@ -221,6 +224,7 @@ -(void) installGestureRecognizers {
221224
UILongPressGestureRecognizer *longPress =
222225
[[UILongPressGestureRecognizer alloc]
223226
initWithTarget:self action:@selector(onLongPress:)];
227+
longPress.cancelsTouchesInView = NO;
224228
[self addGestureRecognizer: longPress];
225229
[longPress release];
226230

@@ -230,6 +234,7 @@ -(void) installGestureRecognizers {
230234
// GESTURE_SCROLL_UPDATE
231235
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc]
232236
initWithTarget:self action:@selector(onScroll:)];
237+
pan.cancelsTouchesInView = NO;
233238
[self addGestureRecognizer: pan];
234239
[pan release];
235240

@@ -238,6 +243,7 @@ -(void) installGestureRecognizers {
238243
// GESTURE_TAP_DOWN
239244
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]
240245
initWithTarget:self action:@selector(onTap:)];
246+
tap.cancelsTouchesInView = NO;
241247
[self addGestureRecognizer: tap];
242248
[tap release];
243249
}

0 commit comments

Comments
 (0)