mirror of
https://github.com/scummvm/scummvm.git
synced 2026-06-20 05:45:29 +00:00
IOS7: Add functions creating UIKeyCommands for special keys
Use the helper function to create an array of UIKeyCommands for the END, HOME, PAGE UP, PAGE DOWN and the ESC keys. Add a generic handler function that decides which action for which key. This allows the application to register key presses of these keys, however some of them requires iOS 13.4 or later.
This commit is contained in:
1 parent
25d7787d9f
commit
c5ef6ecb77
1 file changed
+27
@@ -328,6 +328,16 @@
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSArray *)overloadSpecialKeys {
|
||||
NSMutableArray<NSString *> *specialKeys = [[NSMutableArray alloc] initWithObjects:UIKeyInputEscape, UIKeyInputPageUp, UIKeyInputPageDown, nil];
|
||||
|
||||
if (@available(iOS 13.4, *)) {
|
||||
[specialKeys addObject: UIKeyInputHome];
|
||||
[specialKeys addObject: UIKeyInputEnd];
|
||||
}
|
||||
return [self overloadKeys:specialKeys withSelector:@selector(handleSpecialKey:)];
|
||||
}
|
||||
|
||||
- (int)convertModifierFlags:(UIKeyModifierFlags)flags {
|
||||
return (((flags & UIKeyModifierShift) ? Common::KBD_SHIFT : 0) |
|
||||
((flags & UIKeyModifierControl) ? Common::KBD_CTRL : 0) |
|
||||
@@ -441,6 +451,23 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)handleSpecialKey:(UIKeyCommand *)keyCommand {
|
||||
if (keyCommand.input == UIKeyInputEscape) {
|
||||
[self escapeKey:keyCommand];
|
||||
} else if (keyCommand.input == UIKeyInputPageUp) {
|
||||
[softKeyboard handleKeyPress:Common::KEYCODE_PAGEUP withModifierFlags:[self convertModifierFlags:keyCommand.modifierFlags]];
|
||||
} else if (keyCommand.input == UIKeyInputPageDown) {
|
||||
[softKeyboard handleKeyPress:Common::KEYCODE_PAGEDOWN withModifierFlags:[self convertModifierFlags:keyCommand.modifierFlags]];
|
||||
}
|
||||
if (@available(iOS 13.4, *)) {
|
||||
if (keyCommand.input == UIKeyInputHome) {
|
||||
[softKeyboard handleKeyPress:Common::KEYCODE_HOME withModifierFlags:[self convertModifierFlags:keyCommand.modifierFlags]];
|
||||
} else if (keyCommand.input == UIKeyInputEnd) {
|
||||
[softKeyboard handleKeyPress:Common::KEYCODE_END withModifierFlags:[self convertModifierFlags:keyCommand.modifierFlags]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (NSArray *)keyCommands {
|
||||
UIKeyCommand *upArrow = [UIKeyCommand keyCommandWithInput: UIKeyInputUpArrow modifierFlags: 0 action: @selector(upArrow:)];
|
||||
[self setWantsPriority: upArrow];
|
||||
|
||||
Reference in new issue
Block a user