Cocos2d-x 3.17.1 Editbox SetFocus by Tab key

Hello, Im developer on cocos2d.x.
But not so good expert.
I have a problem on cocos2d-x 3.17.1 Lua probject.
My problem is below as:
I have a project with 2 ccui:Editbox.
I want to set the cursor to next Editbox when I click Tab key(on windows platform).
So When I click Tab key, I want to move cursor to other Editbox.
But I can not find solution.

local function key_return(keyCode, ref)
local platform = cc.Application:getInstance():getTargetPlatform()
if cc.PLATFORM_OS_WINDOWS == platform then
if keyCode == 8 then --TAB key
if toFillAcc then
–self.account:setFocused(false)
self.password:setFocused()
toFillAcc = false
else
–self.password:setFocused(false)
self.account:setFocused()
toFillAcc = true
end
elseif (keyCode == 35 or keyCode == 164) then --enter key
onClickLogin(nil, ccui.TouchEventType.ended)
end
end
end

local key_listener = cc.EventListenerKeyboard:create()
key_listener:registerScriptHandler(key_return, cc.Handler.EVENT_KEYBOARD_RELEASED)

local eventDispatcher = scene:getEventDispatcher()
eventDispatcher:addEventListenerWithSceneGraphPriority(key_listener, scene)

This is my code.
I hope solve this soon.
Thanks.

1 Like