diff options
author | Vincent Bénony | 2015-12-01 19:02:05 +0100 |
---|---|---|
committer | Vincent Bénony | 2016-01-06 15:35:31 +0100 |
commit | e82a46c2e3b169994a00404b287ce583c46c4291 (patch) | |
tree | 4ecdce1c5e8e96398e50fcda92ba87e1802745d5 /backends | |
parent | 13580b7ac57e29c362c1924d0211766390fd0b8e (diff) | |
download | scummvm-rg350-e82a46c2e3b169994a00404b287ce583c46c4291.tar.gz scummvm-rg350-e82a46c2e3b169994a00404b287ce583c46c4291.tar.bz2 scummvm-rg350-e82a46c2e3b169994a00404b287ce583c46c4291.zip |
IOS: Fixes the virtual keyboard
Diffstat (limited to 'backends')
-rw-r--r-- | backends/platform/iphone/iphone_keyboard.h | 5 | ||||
-rw-r--r-- | backends/platform/iphone/iphone_keyboard.mm | 45 |
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 |