Skip to content

Commit

Permalink
IOS: Add support for three finger swipes up/down for showing/hiding s…
Browse files Browse the repository at this point in the history
…oftware keyboard
  • Loading branch information
jonnyijapan authored and criezy committed Feb 16, 2019
1 parent 4795f2b commit a9a6ce7
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions backends/platform/ios7/ios7_video.mm
Expand Up @@ -349,6 +349,19 @@ - (void)deleteTextures {
}

- (void)setupGestureRecognizers {
const NSUInteger KEYBOARDSWIPETOUCHCOUNT = 3;
UISwipeGestureRecognizer *swipeUpKeyboard = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(keyboardSwipeUp:)];
swipeUpKeyboard.direction = UISwipeGestureRecognizerDirectionUp;
swipeUpKeyboard.numberOfTouchesRequired = KEYBOARDSWIPETOUCHCOUNT;
swipeUpKeyboard.delaysTouchesBegan = NO;
swipeUpKeyboard.delaysTouchesEnded = NO;

UISwipeGestureRecognizer *swipeDownKeyboard = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(keyboardSwipeDown:)];
swipeDownKeyboard.direction = UISwipeGestureRecognizerDirectionDown;
swipeDownKeyboard.numberOfTouchesRequired = KEYBOARDSWIPETOUCHCOUNT;
swipeDownKeyboard.delaysTouchesBegan = NO;
swipeDownKeyboard.delaysTouchesEnded = NO;

UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(twoFingersSwipeRight:)];
swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
swipeRight.numberOfTouchesRequired = 2;
Expand Down Expand Up @@ -379,12 +392,16 @@ - (void)setupGestureRecognizers {
doubleTapTwoFingers.delaysTouchesBegan = NO;
doubleTapTwoFingers.delaysTouchesEnded = NO;

[self addGestureRecognizer:swipeUpKeyboard];
[self addGestureRecognizer:swipeDownKeyboard];
[self addGestureRecognizer:swipeRight];
[self addGestureRecognizer:swipeLeft];
[self addGestureRecognizer:swipeUp];
[self addGestureRecognizer:swipeDown];
[self addGestureRecognizer:doubleTapTwoFingers];

[swipeUpKeyboard release];
[swipeDownKeyboard release];
[swipeRight release];
[swipeLeft release];
[swipeUp release];
Expand Down Expand Up @@ -1013,6 +1030,14 @@ - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
_secondTouch = nil;
}

- (void)keyboardSwipeUp:(UISwipeGestureRecognizer *)recognizer {
[self showKeyboard];
}

- (void)keyboardSwipeDown:(UISwipeGestureRecognizer *)recognizer {
[self hideKeyboard];
}

- (void)twoFingersSwipeRight:(UISwipeGestureRecognizer *)recognizer {
[self addEvent:InternalEvent(kInputSwipe, kUIViewSwipeRight, 2)];
}
Expand Down

0 comments on commit a9a6ce7

Please sign in to comment.