viewNode.inputUserID:setInputMode(cc.EDITBOX_INPUT_MODE_NUMERIC) --设置editBox输入模式是数字,但还是可以输入,.+#等字符
viewNode.inputUserID:setMaxLength(MAX_USERID_LEN)
viewNode.inputUserID:registerScriptEditBoxHandler(handler(self, self.onInputUserIDChanged)) --在onInputUserIDChanged中做处理
function CLASS:onInputUserIDChanged(strEventName, pSender)
if strEventName ~= "changed" then return end
--only input for number
if self._viewNode and self._viewNode.inputUserID then
local str = self._viewNode.inputUserID:getString()
local astr = string.match(str, "%d+")
self._viewNode.inputUserID:setString(astr)
print(astr)
end
end
editBox编辑框绑定事件registerScriptEditBoxHandler:
--定义编辑框CCEditBox的回调事件
local function editBoxTextEventH