游戏login的时候必须要求玩家输入用户名、密码,还要可以删除。

cocostudio画一个textfield,直接读入好了;

textField类,继承读取的widget。

local textField = class("textField", function GUIReader:shareReader():widgetFromJsonFile(jsonPath)  end)

--获得textField组件

function testField:ctor()

  self.mTextField_input = tolua.cast(Helper:seekWidgetByName(self, "textField_m"), "ccui.TextField")

  self:addCallback()

end

--注册回调

function testField:addCallback()

  local keyListener = cc.EventListenerKeyBoard:create()

  keyListener:registerScriptHandler(handler(self, self.onkeyPressed), cc.Handler.EVENT_KEYBOARD_PRESSED)

  local currentScene = l_command.getCurrentScene()

  currentScene:getEventDispatcher():addEventListenerWithSceneGraphPrioprity(keyListener, currentScene)

  

end

--删除事件,删除字母

function testField:onkeyPressed(keycode, event)

  if keycode == cc.Keycode.KEYBACKSPACE then

     local str = self.mTextField_input:getStringValue()

     str = string.sub(str, 0, string.len(str) - 1)

     self.mTextField_input:setText(str)

  end

end

最新文章

  1. JSTL 核心标签库 使用
  2. NodeJS系列~第二个小例子,解决中文乱码的问题
  3. JMeter入门合集
  4. HDU 4081 Qin Shi Huang's National Road System [次小生成树]
  5. 数组对象Vector用法
  6. mvc5 + ef6 + autofac搭建项目(repository+uow)(二)
  7. CRM权限管理
  8. 2015苏州大学ACM-ICPC集训队选拔赛(3)题解
  9. 201621123067《JAVA程序设计》第一周学习总结
  10. python爬虫爬取代理IP
  11. CNCC2017中的深度学习与跨媒体智能
  12. Redis数据结构和常用API
  13. RESTful API浅谈
  14. spring-boot-actuator报错Full authentication is required to access this resource
  15. L1正则和L2正则的比较分析详解
  16. Mysql 视图使用
  17. MySQL常见错误代码及代码说明
  18. 20172321 2017-2018-2《Java程序设计》第三周学习总结
  19. spring框架学习(七)spring管理事务方式之xml配置
  20. 将数据库dbcp连接池改为c3p0连接池(草稿,别点)

热门文章

  1. R-TREE
  2. makefile 中autoload
  3. windows 7安装apache
  4. php获取POST数据的三种方法
  5. 【ES】学习3-请求体查询
  6. PreparedStatement setDate setTimestamp ,util.date sql.date区别
  7. ThinkPHP中where()使用方法详解
  8. WCF客户端从服务器下载数据
  9. Mybatis中的like模糊查询四种方式
  10. canvas画多边形