您的位置:首页 > 移动开发 > Cocos引擎

cocos2d-x lua 监听editBox

2018-03-21 15:25 239 查看
self.accountName = ccui.EditBox:create({width=335,height=74}, "Common2/M_LoginInputBg.png");  --创建一个EditBox
self.accountName:setPosition(350, 190); --设置EditBox位置
self.accountName:setFont("Common2/FZY3JW.TTF", 35);   --设置文本字体
self.accountName:setPlaceholderFont("Common2/FZY3JW.TTF", 35);   --设置占位文本字体
self.accountName:setPlaceHolder("");  --设置占位文本内容
self.accountName:setMaxLength(14);    --设置文本长度
self.accountName:registerScriptEditBoxHandler(_CallSelfFun(self, self.onAccountChange));  --监听EditBox
--self.accountName:registerScriptEditBoxHandler(self.onAccountChange(self)));--监听EditBox(此方法同样适用)
self.loginPanel:addChild(self.accountName);

function UILogin:onAccountChange(sender, eventType)   --监听回调
    if type(sender) == "string" then                  
        if sender == "changed" then
        end
    else
    end
end

--self函数
function _CallSelfFun(self, selfFun)
    local callSelfFun = function(...)
    selfFun(self, ...);   
    end    
    return callSelfFun;
end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: