IOS7: Toggle keyboard with on-screen control button

Add a long press gesture to the touch mode control button, which
when triggered, shows the keyboard. The image of the UI button
changes to the keyboard image asset as long as the keyboard is
visible. If pressing the touch mode control button while the
keyboard is visible it will dismiss the keyboard.

The updates of the on-screen button image is done in the general
"showKeyboard" and "hideKeyboard" functions which makes sure that
the button image is updated also if showing/hiding of the keyboard
is triggered by the OSystem callback.
This commit is contained in:
Lars Sundström 2023-10-03 21:56:42 +02:00
parent 00296153df
commit 316352e868

View File

@ -184,6 +184,11 @@ bool iOS7_fetchEvent(InternalEvent *event) {
- (void)setupGestureRecognizers {
#if TARGET_OS_IOS
UILongPressGestureRecognizer *longPressKeyboard = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressKeyboard:)];
[longPressKeyboard setMinimumPressDuration:1];
[_toggleTouchModeButton addGestureRecognizer:longPressKeyboard];
[longPressKeyboard release];
UIPinchGestureRecognizer *pinchKeyboard = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(keyboardPinch:)];
UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(twoFingersSwipeRight:)];
@ -337,7 +342,11 @@ bool iOS7_fetchEvent(InternalEvent *event) {
#if TARGET_OS_IOS
- (void)triggerTouchModeChanged {
if ([self isKeyboardShown]) {
[self hideKeyboard];
} else {
[self addEvent:InternalEvent(kInputTouchModeChanged, 0, 0)];
}
}
- (void)updateTouchMode {
@ -525,10 +534,16 @@ bool iOS7_fetchEvent(InternalEvent *event) {
- (void)showKeyboard {
[_keyboardView showKeyboard];
#if TARGET_OS_IOS
[_toggleTouchModeButton setImage:[UIImage imageNamed:@"ic_action_keyboard"] forState:UIControlStateNormal];
#endif
}
- (void)hideKeyboard {
[_keyboardView hideKeyboard];
#if TARGET_OS_IOS
[self updateTouchMode];
#endif
}
- (BOOL)isKeyboardShown {
@ -620,6 +635,14 @@ bool iOS7_fetchEvent(InternalEvent *event) {
#endif
#if TARGET_OS_IOS
- (void)longPressKeyboard:(UILongPressGestureRecognizer *)recognizer {
if (![self isKeyboardShown]) {
if (recognizer.state == UIGestureRecognizerStateBegan) {
[self showKeyboard];
}
}
}
- (void)keyboardPinch:(UIPinchGestureRecognizer *)recognizer {
if ([recognizer scale] < 0.8)
[self showKeyboard];