Skip to content

Commit 6e6b37b

Browse files
authored
fix issue that can not receive Chinese characters with system input m… (#20232)
1 parent 75db613 commit 6e6b37b

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

cocos/platform/ios/CCInputView-ios.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#import <UIKit/UIKit.h>
22

3-
@interface CCInputView : UIView <UIKeyInput>
3+
@interface CCInputView : UIView <UITextInput>
44
@end

cocos/platform/ios/CCInputView-ios.mm

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,18 @@ @implementation CCInputView
1414
@synthesize myMarkedText;
1515
@synthesize isKeyboardShown;
1616

17+
@synthesize hasText;
18+
@synthesize selectedTextRange;
19+
@synthesize beginningOfDocument;
20+
@synthesize endOfDocument;
21+
@synthesize markedTextStyle;
22+
@synthesize tokenizer;
23+
@synthesize autocorrectionType;
24+
1725
- (instancetype) initWithFrame:(CGRect)frame {
1826
if (self = [super initWithFrame:frame] ) {
1927
self.myMarkedText = nil;
28+
self.autocorrectionType = UITextAutocorrectionTypeNo;
2029
}
2130

2231
return self;
@@ -35,14 +44,14 @@ - (void)didMoveToWindow
3544
[[NSNotificationCenter defaultCenter] addObserver:self
3645
selector:@selector(onUIKeyboardNotification:)
3746
name:UIKeyboardWillShowNotification object:nil];
38-
47+
3948
[[NSNotificationCenter defaultCenter] addObserver:self
4049
selector:@selector(onUIKeyboardNotification:)
4150
name:UIKeyboardDidShowNotification object:nil];
4251
[[NSNotificationCenter defaultCenter] addObserver:self
4352
selector:@selector(onUIKeyboardNotification:)
4453
name:UIKeyboardWillHideNotification object:nil];
45-
54+
4655
[[NSNotificationCenter defaultCenter] addObserver:self
4756
selector:@selector(onUIKeyboardNotification:)
4857
name:UIKeyboardDidHideNotification object:nil];
@@ -62,6 +71,14 @@ - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
6271

6372
#pragma TextInput protocol
6473

74+
- (id<UITextInputDelegate>)inputDelegate {
75+
return nil;
76+
}
77+
78+
- (void)setInputDelegate:(id<UITextInputDelegate>)inputDelegate {
79+
80+
}
81+
6582
- (void)deleteBackward {
6683
if (nil != self.myMarkedText) {
6784
[self.myMarkedText release];
@@ -178,7 +195,7 @@ - (nullable NSString *)textInRange:(nonnull UITextRange *)range {
178195
if (nil != self.myMarkedText) {
179196
return self.myMarkedText;
180197
}
181-
return nil;
198+
return @"";
182199
}
183200

184201
- (nullable UITextRange *)textRangeFromPosition:(nonnull UITextPosition *)fromPosition toPosition:(nonnull UITextPosition *)toPosition {
@@ -327,6 +344,4 @@ - (void)onUIKeyboardNotification:(NSNotification *)notif
327344
}
328345
}
329346

330-
@synthesize hasText;
331-
332347
@end

0 commit comments

Comments
 (0)