cocos2d / cocos2d-html5

Cocos2d for Web Browsers. Built using JavaScript.
https://www.cocos.com
3.06k stars 903 forks source link

Bug report about ccui.TextField #3535

Closed acrazing closed 4 years ago

acrazing commented 6 years ago

ENV:

Problems:

  1. setContentSize/setTextAreaSize does not work on any platform
  2. setTextHorizontalAlignment/setTextVerticalAlignment does not work on any platform if call setAnchorPoint(0, 0), else works on iOS but does not work on mobile/pc browsers
  3. long text(overflow) could not hide
  4. prompt input does not work on pc browser(Chrome)
  5. only if touches on the placeholder or text could attach IME
  6. IME does not hide when touches the area does not in the input box

The example code:

    var input = new ccui.TextField('Please input text', void 0, 18 * 2);
    input.setAnchorPoint(0.5, 0.5);
    input.setTextAreaSize(cc.size(cc.sys.windowPixelResolution.width - 40, 30 * 2));
    input.setPosition(cc.sys.windowPixelResolution.width / 2, cc.sys.windowPixelResolution.height - 200 + 30);
    cc.sys.isNative || input.getVirtualRenderer().setTipMessage(input.getPlaceHolder());
    input.setPlaceHolderColor(cc.color(0x99, 0x99, 0x99));
    input.setTextColor(cc.color(0xff, 0xff, 0xff));
    input.setTextHorizontalAlignment(cc.TEXT_ALIGNMENT_CENTER);
    input.setTextVerticalAlignment(cc.VERTICAL_TEXT_ALIGNMENT_CENTER);
    this.addChild(input, 100);

The results:

wechatimg20 The text at center on mobile browser

wechatimg19 The text at left on mobile browser

wechatimg18 The text at center on iOS

wechatimg17 The placeholder at center on iOS

wechatimg16 The input text still show when overflow

acrazing commented 4 years ago