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
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
相关文章推荐
- cocos2d-lua3.7控件篇(一)-EditBox
- cocos2d-x3.2 lua 返回键监听
- 使用Cocos2d-lua开发植物大战僵尸07-实现开始游戏按钮功能和主场景触摸监听
- Cocos2d-x 脚本语言Lua的使用
- Cocos2d-x 3.0 lua编程 实现在Android下响应Home键和Back键
- 一些cocos2d-x + lua学习资料备忘[持续更新]
- cocos2d-x lua分支加载ccbi文件
- Cocos2d-x 脚本语言Lua基本数据结构-表(table)
- Cocos2d-x 3.0final 终结者系列教程19脚本编程-Lua语法基础
- 【Cocos2d-x游戏开发lua篇之基础】加载图片与设置按钮监听事件
- Cocos2d-x下Lua调用自定义C++类和函数的最佳实践
- Cocos2d-x Lua游戏开发之Lua oo 的实现
- Cocos2d-x中Lua与C++通信
- 如何在cocos2d c++代码中调用lua以及探究
- lua监听内存释放
- Cocos2d-lua的运行理解
- 使用Cocos2d-lua开发植物大战僵尸09-实现添加植物
- cocos2d-Lua视频教程
- Quick-Cocos2d-x 3.3绑定自定义类至Lua(四)使用绑定C++至Lua的自定义类
- vs2013开发调试cocos2d-x-Lua工程项目