IOS: Fix Arrow Key Capture in TextInputHandler.

This should fix these working from external keyboards i.e. IPad Pro and
other sources as well.

This is presumably what the original author intended.
This commit is contained in:
Michael Zinn 2018-08-16 19:20:21 +02:00 committed by D G Turner
parent 4865b02e39
commit 82e8bc43e6

View File

@ -53,6 +53,30 @@
return self;
}
- (NSArray *)keyCommands {
UIKeyCommand *upArrow = [UIKeyCommand keyCommandWithInput: UIKeyInputUpArrow modifierFlags: 0 action: @selector(upArrow:)];
UIKeyCommand *downArrow = [UIKeyCommand keyCommandWithInput: UIKeyInputDownArrow modifierFlags: 0 action: @selector(downArrow:)];
UIKeyCommand *leftArrow = [UIKeyCommand keyCommandWithInput: UIKeyInputLeftArrow modifierFlags: 0 action: @selector(leftArrow:)];
UIKeyCommand *rightArrow = [UIKeyCommand keyCommandWithInput: UIKeyInputRightArrow modifierFlags: 0 action: @selector(rightArrow:)];
return [[NSArray alloc] initWithObjects: upArrow, downArrow, leftArrow, rightArrow, nil];
}
- (void) upArrow: (UIKeyCommand *) keyCommand {
[softKeyboard handleKeyPress:273];
}
- (void) downArrow: (UIKeyCommand *) keyCommand {
[softKeyboard handleKeyPress:274];
}
- (void) leftArrow: (UIKeyCommand *) keyCommand {
[softKeyboard handleKeyPress:276];
}
- (void) rightArrow: (UIKeyCommand *) keyCommand {
[softKeyboard handleKeyPress:275];
}
@end
@ -66,30 +90,6 @@
return self;
}
- (NSArray *)keyCommands {
UIKeyCommand *upArrow = [UIKeyCommand keyCommandWithInput: UIKeyInputUpArrow modifierFlags: 0 action: @selector(upArrow:)];
UIKeyCommand *downArrow = [UIKeyCommand keyCommandWithInput: UIKeyInputDownArrow modifierFlags: 0 action: @selector(downArrow:)];
UIKeyCommand *leftArrow = [UIKeyCommand keyCommandWithInput: UIKeyInputLeftArrow modifierFlags: 0 action: @selector(leftArrow:)];
UIKeyCommand *rightArrow = [UIKeyCommand keyCommandWithInput: UIKeyInputRightArrow modifierFlags: 0 action: @selector(rightArrow:)];
return [[NSArray alloc] initWithObjects: upArrow, downArrow, leftArrow, rightArrow, nil];
}
- (void) upArrow: (UIKeyCommand *) keyCommand {
[self handleKeyPress:273];
}
- (void) downArrow: (UIKeyCommand *) keyCommand {
[self handleKeyPress:274];
}
- (void) leftArrow: (UIKeyCommand *) keyCommand {
[self handleKeyPress:276];
}
- (void) rightArrow: (UIKeyCommand *) keyCommand {
[self handleKeyPress:275];
}
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
unichar c;
if (text.length) {