Skip to content

Commit

Permalink
fix issues of textfield (cocos2d#20303)
Browse files Browse the repository at this point in the history
* fix infinite loop

* fix issue that touch event does not match
If click area ouside keyboard, then engine only receive touch begin event witouth touch end or touch cancled event.
  • Loading branch information
minggo committed Nov 14, 2019
1 parent 846e57b commit 282f3fa
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cocos/platform/ios/CCEAGLView-ios.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved.
@property(nonatomic,readonly) EAGLContext *context;

@property(nonatomic,readwrite) BOOL multiSampling;
@property(nonatomic, readonly) BOOL isKeyboardShown;


/** CCEAGLView uses double-buffer. This method swaps the buffers */
Expand All @@ -132,5 +133,4 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved.

-(void) showKeyboard;
-(void) hideKeyboard;
-(BOOL) isKeyboardShown;
@end
7 changes: 1 addition & 6 deletions cocos/platform/ios/CCEAGLView-ios.mm
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE

@interface CCEAGLView ()
@property (nonatomic) CCInputView* textInputView;
@property(nonatomic) BOOL isKeyboardShown;
@property(nonatomic, readwrite, assign) BOOL isKeyboardShown;
@property(nonatomic, copy) NSNotification* keyboardShowNotification;
@property(nonatomic, assign) CGRect originalRect;
@end
Expand Down Expand Up @@ -472,11 +472,6 @@ - (void) hideKeyboard
[self.textInputView removeFromSuperview];
}

-(BOOL) isKeyboardShown
{
return self.isKeyboardShown;
}

-(void) doAnimationWhenKeyboardMoveWithDuration:(float) duration distance:(float) dis
{
[UIView beginAnimations:nil context:nullptr];
Expand Down
3 changes: 1 addition & 2 deletions cocos/platform/ios/CCInputView-ios.mm
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,12 @@ - (BOOL) canBecomeFirstResponder {
return YES;
}

- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[self resignFirstResponder];
[self removeFromSuperview];
}


#pragma TextInput protocol

- (id<UITextInputDelegate>)inputDelegate {
Expand Down

0 comments on commit 282f3fa

Please sign in to comment.