Skip to content

Commit

Permalink
Fixed another issue with gesture recognizer in iOS 13. Changed to der…
Browse files Browse the repository at this point in the history
…ive from UIGestureRecognizer rather than UITapGestureRecognizer because in iOS13 the tap gesture recognizer seems to timeout after a second or two, which makes the app appear to lock up. This should resolve codenameone#2928
  • Loading branch information
shannah committed Sep 24, 2019
1 parent fbd75e8 commit df13497
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Ports/iOSPort/nativeSources/CN1TapGestureRecognizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#import <UIKit/UIGestureRecognizerSubclass.h>
#import "CodenameOne_GLViewController.h"

@interface CN1TapGestureRecognizer : UITapGestureRecognizer<UIGestureRecognizerDelegate> {
@interface CN1TapGestureRecognizer : UIGestureRecognizer<UIGestureRecognizerDelegate> {
UIView* pressedView;
}
- (void) install:(CodenameOne_GLViewController*)ctrl;
Expand Down
11 changes: 11 additions & 0 deletions Ports/iOSPort/nativeSources/CN1TapGestureRecognizer.m
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,13 @@ - (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesMoved:touches withEvent:event];
self.state = UIGestureRecognizerStateBegan;
// WARNING: DO NOT try to call super touchesMoved or touchesEnd
// event won't be delivered on iOS 13 and up.
// See https://groups.google.com/d/msgid/codenameone-discussions/9084cc3f-df2d-47f9-a6a7-036ad6e41a72%40googlegroups.com
if(skipNextTouch || (editingComponent != nil && !isVKBAlwaysOpen())) {
self.state = UIGestureRecognizerStateCancelled;
return;
}
POOL_BEGIN();
Expand All @@ -143,6 +146,7 @@ - (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
// skip this. We were getting pointer events
// handled here when the gallery was opened:
// https://github.com/codenameone/CodenameOne/issues/2793
self.state = UIGestureRecognizerStateCancelled;
POOL_END();
return;
}
Expand Down Expand Up @@ -170,13 +174,15 @@ - (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
[super touchesEnded:touches withEvent:event];
if(skipNextTouch) {
skipNextTouch = NO;
self.state = UIGestureRecognizerStateCancelled;
return;
}
POOL_BEGIN();
NSArray *ts = [touches allObjects];
[touchesArray removeObjectsInArray:ts];
if([touchesArray count] > 0) {
POOL_END();

return;
}
UITouch* touch = [touches anyObject];
Expand All @@ -188,6 +194,7 @@ - (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
// skip this. We were getting pointer events
// handled here when the gallery was opened:
// https://github.com/codenameone/CodenameOne/issues/2793
self.state = UIGestureRecognizerStateCancelled;
POOL_END();
return;
}
Expand All @@ -209,6 +216,7 @@ - (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
[ctrl foldKeyboard:point];
}
pointerReleasedC(xArray, yArray, [touches count]);
self.state = UIGestureRecognizerStateEnded;
POOL_END();
}

Expand All @@ -217,6 +225,7 @@ - (void) touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
[super touchesCancelled:touches withEvent:event];
if(skipNextTouch) {
skipNextTouch = NO;
self.state = UIGestureRecognizerStateCancelled;
return;
}
POOL_BEGIN();
Expand All @@ -231,6 +240,7 @@ - (void) touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
// skip this. We were getting pointer events
// handled here when the gallery was opened:
// https://github.com/codenameone/CodenameOne/issues/2793
self.state = UIGestureRecognizerStateCancelled;
POOL_END();
return;
}
Expand All @@ -250,6 +260,7 @@ - (void) touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
[ctrl foldKeyboard:point];
}
pointerReleasedC(xArray, yArray, [touches count]);
self.state = UIGestureRecognizerStateCancelled;
POOL_END();
}
- (void) ignoreTouch:(UITouch *)touch forEvent:(UIEvent *)event
Expand Down

0 comments on commit df13497

Please sign in to comment.