Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refine editbox begin editing callback #5732

Merged
merged 2 commits into from Nov 16, 2019

Conversation

@umbrellaPP
Copy link
Contributor

umbrellaPP commented Nov 13, 2019

changeLog:

  • 修复 editBox 在 editing-did-began 回调里无法设置 editBox.string 的问题

应该在 showDom 之前执行用户注册的回调,这样用户才能看到他们期望看到的结果

@holycanvas

This comment has been minimized.

Copy link
Contributor

holycanvas commented Nov 14, 2019

我担心这种修复可能会导致其他问题,editBoxEditingDidBegan 这个事件在showDom之后触发我觉得是没问题的,因为用户注册的回调有可能是基于editbox显示之后做的一些处理,如果提前触发,这时候editbox还没显示出来,回调中的某些逻辑可能会报错。

string的这个问题,能不能在editbox显示出来之后再动态改呢?如果不行的话,我们是不是要考虑再加一个事件,比如beforeEditBoxShown

@holycanvas holycanvas requested a review from jareguo Nov 14, 2019
PP
@umbrellaPP

This comment has been minimized.

Copy link
Contributor Author

umbrellaPP commented Nov 15, 2019

再次调整下 editBoxEditingDidBegan 的位置到状态位标记完之后调用,防止 editBox.isFocused() 判断出错

因为用户注册的回调有可能是基于editbox显示之后做的一些处理,如果提前触发,这时候editbox还没显示出来,回调中的某些逻辑可能会报错

dom 显示之后,用户能做的操作很少,希望用户在回调里用 editBox 提供的接口,而不是直接操作 dom 节点

string的这个问题,能不能在editbox显示出来之后再动态改呢?

目前的实现是 showDom 的时候做一次文本内容和样式的同步,不然用户随时随地都可能设置 editBox.string 和样式,要做各种事件监听,太麻烦了

目前的调整是把用户的 editing-did-began 回调逻辑放到 showDom 和 dom.focus 的操作之前,其他的不变

@jareguo jareguo merged commit e6d0a51 into cocos-creator:v2.2.1-release Nov 16, 2019
1 check passed
1 check passed
ci/circleci: test Your tests passed on CircleCI!
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.