Closed jeromeyan closed 9 years ago
I didn't understand why did use width to calculate textField's y position.
Please try to use this:
textField.y = (cc.winSize.height+ textField.height) / 2;
Hopes to help David
Hi dingpinglv,
Sorry, it should be the x property. Just now I fixed the problem by the following formula:
textField.x = (cc.winSzie.width + textField.getVirtualRendererSize().width) / 2;
Seems we shall not use the widht or height property of textField directly.
Hi @jeromeyan ,
ccui.TextFiled's height property is a function to return contentSize.height. I'll test this issue your feedback.
Thanks, David
This issue has been fixed at : https://github.com/cocos2d/cocos2d-html5/pull/2634
Cocos2d-x will fix it soon.
Thanks for feedback. David
I am trying to align the left of the TextField at the midle of the Scene. So I use the bellow formula to calculate the value for the textField.y.
textField.x = (cc.winSize.width + textField.width) / 2;
When there are EVENT_INSERT_TEXTor EVENT_DELETE_BACKWARD event fired on this textField, I use the above formula to re-calculate the textField.y again. And I also print the textField.width to see the actual width change. I set the textField.placeHolder to "Please input your user name ...". So at the first EVENT_INSERT_TEXT event, it prints the textField.width = 290, but from the second input character, I sae the textField.width increase from 11. When I press the backward key, the textField.width decrease accordingly, I press the backward key until there is no input in the textField, it shows the textField.width = 11, but actually currently the textField shows the placeHolder string, and it looks like jumps to the left, looks very ugly.
I think the textField.width value is mis-calculated every time at the event, I believe that it holds the previous value.
Please take a look at this.