From a9a6ce7e811a2a3fe14399a868341031b54517a0 Mon Sep 17 00:00:00 2001 From: Jonny Bergström Date: Sun, 21 Oct 2018 08:45:40 +0900 Subject: IOS: Add support for three finger swipes up/down for showing/hiding software keyboard --- backends/platform/ios7/ios7_video.mm | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'backends/platform/ios7') diff --git a/backends/platform/ios7/ios7_video.mm b/backends/platform/ios7/ios7_video.mm index 679dedffc4..b00ecf64f9 100644 --- a/backends/platform/ios7/ios7_video.mm +++ b/backends/platform/ios7/ios7_video.mm @@ -349,6 +349,19 @@ uint getSizeNextPOT(uint size) { } - (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; @@ -379,12 +392,16 @@ uint getSizeNextPOT(uint size) { 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]; @@ -1013,6 +1030,14 @@ uint getSizeNextPOT(uint size) { _secondTouch = nil; } +- (void)keyboardSwipeUp:(UISwipeGestureRecognizer *)recognizer { + [self showKeyboard]; +} + +- (void)keyboardSwipeDown:(UISwipeGestureRecognizer *)recognizer { + [self hideKeyboard]; +} + - (void)twoFingersSwipeRight:(UISwipeGestureRecognizer *)recognizer { [self addEvent:InternalEvent(kInputSwipe, kUIViewSwipeRight, 2)]; } -- cgit v1.2.3