aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/platform/iphone/iphone_keyboard.h5
-rw-r--r--backends/platform/iphone/iphone_keyboard.mm45
2 files changed, 28 insertions, 22 deletions
diff --git a/backends/platform/iphone/iphone_keyboard.h b/backends/platform/iphone/iphone_keyboard.h
index d54df9ac96..ddd8f436e5 100644
--- a/backends/platform/iphone/iphone_keyboard.h
+++ b/backends/platform/iphone/iphone_keyboard.h
@@ -26,7 +26,7 @@
#include <UIKit/UIKit.h>
#include <UIKit/UITextView.h>
-@interface SoftKeyboard : UIView {
+@interface SoftKeyboard : UIView<UITextViewDelegate> {
id inputDelegate;
UITextView *inputView;
}
@@ -36,6 +36,9 @@
- (void)setInputDelegate:(id)delegate;
- (void)handleKeyPress:(unichar)c;
+- (void)showKeyboard;
+- (void)hideKeyboard;
+
@end
#endif
diff --git a/backends/platform/iphone/iphone_keyboard.mm b/backends/platform/iphone/iphone_keyboard.mm
index 39d68aff81..0588aac8ab 100644
--- a/backends/platform/iphone/iphone_keyboard.mm
+++ b/backends/platform/iphone/iphone_keyboard.mm
@@ -43,31 +43,13 @@
self = [super initWithFrame:CGRectMake(0.0f, 0.0f, 0.0f, 0.0f)];
softKeyboard = keyboard;
- [[self textInputTraits] setAutocorrectionType:(UITextAutocorrectionType)1];
- [[self textInputTraits] setAutocapitalizationType:(UITextAutocapitalizationType)0];
- [[self textInputTraits] setEnablesReturnKeyAutomatically:NO];
+ [self setAutocorrectionType:UITextAutocorrectionTypeNo];
+ [self setAutocapitalizationType:UITextAutocapitalizationTypeNone];
+ [self setEnablesReturnKeyAutomatically:NO];
return self;
}
-- (void) keyboardInputShouldDelete:(id)input {
- [softKeyboard handleKeyPress:0x08];
-}
-
-- (BOOL)webView:(id)fp8 shouldInsertText:(id)character
- replacingDOMRange:(id)fp16
- givenAction:(int)fp20 {
-
- if ([character length] != 1) {
- [NSException raise:@"Unsupported" format:@"Unhandled multi-char insert!"];
- return NO;
- }
-
- [softKeyboard handleKeyPress:[character characterAtIndex:0]];
-
- return NO;
-}
-
@end
@@ -77,9 +59,22 @@
self = [super initWithFrame:frame];
inputDelegate = nil;
inputView = [[TextInputHandler alloc] initWithKeyboard:self];
+ inputView.delegate = self;
return self;
}
+- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
+ unichar c;
+ if (text.length) {
+ c = [text characterAtIndex:0];
+ }
+ else {
+ c = '\b';
+ }
+ [inputDelegate handleKeyPress:c];
+ return YES;
+}
+
- (UITextView *)inputView {
return inputView;
}
@@ -92,4 +87,12 @@
[inputDelegate handleKeyPress:c];
}
+- (void)showKeyboard {
+ [inputView becomeFirstResponder];
+}
+
+- (void)hideKeyboard {
+ [inputView endEditing:YES];
+}
+
@end