cocos2d-x lua 监听editBox

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

猜你喜欢

转载自blog.csdn.net/u014206831/article/details/79640750
今日推荐