cocos2d-x textField多行输入

可以在触摸函数中进行判断是否点击,并弹出键盘
function onTouchBegan(touch ,event)
local isClicked = self ._textField:boundingBox():containsPoint(touch:getLocation())
if (isClicked) then

      --弹出软键盘
         self._textField:attachWithIME()
     end

end

self._textField = ccui.TextField:create("hello easy!","Arial", 36)
self._textField:setPosition(cc.p(500, 300))
self._textField:setMaxLength(240)
self._textField:setMaxLengthEnabled( true)
self._textField:ignoreContentAdaptWithSize( false)-------------关键
self._textField:setContentSize(cc.size(600, 80))---------------关键

self:addChild(self ._textField)
self._textField:setTouchEnabled( true)
也可以直接添加监听函数
textField->addEventListener(textFieldEvent)
local function textFieldEvent(ref, event)

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。