UIEditBox 控件的使用 点击输入框 自动切换 到下一个输入框 并上移 背景
Quick-3.5
local editAccount,editPwd
local function editBoxEventHandler(strEventName,pSender)
local edit = pSender:getName()
if strEventName == "return" then
if edit == "editAccount" then
local _delay = function ()
if not tolua.isnull(editPwd) then
editPwd:touchDownAction(editPwd, TOUCH_EVENT_ENDED)
end
end
scheduler.performWithDelayGlobal(_delay, 0)
end
end
end
editAccount = cc.ui.UIInput.newEditBox_({
size = cc.size(340, 60),
image = "space.png"
})
editAccount:setAnchorPoint(cc.p(0,0.3))
editAccount:setName("editAccount")
editAccount:setPlaceHolder("4-20位字母或数字组成")
editAccount:setPlaceholderFont("fonts/fzzy.ttf",24)
editAccount:setMaxLength(40)
editAccount:setInputMode(cc.EDITBOX_INPUT_MODE_EMAILADDR)
editAccount:setReturnType(cc.KEYBOARD_RETURNTYPE_DEFAULT)
editAccount:registerScriptEditBoxHandler(editBoxEventHandler)
self.textFileAccount:addChild(editAccount, 2)
editPwd = cc.ui.UIInput.newEditBox_({
size = cc.size(340, 60),
image = "space.png"
})
editPwd:setAnchorPoint(cc.p(0,0.3))
editPwd:setPlaceHolder("6-20位字母或数字组成")
editPwd:setPlaceholderFont("fonts/fzzy.ttf",24)
editPwd:setMaxLength(20)
editPwd:setInputMode(cc.EDITBOX_INPUT_MODE_SINGLELINE)
editPwd:setInputFlag(cc.EDITBOX_INPUT_FLAG_PASSWORD)
editPwd:setReturnType(cc.KEYBOARD_RETURNTYPE_DEFAULT)
self.textFieldPassword:addChild(editPwd, 2)