Hi,
I was trying native keyboard last night and it I bumped into a problem. I have a username field and password field. After finishing typing in my username field, I press “next” and the cursor goes to the password field and then vanish straight away.
Here’s my code:
-- USERNAME -- local function onUser(e) if(e.phase == "began") then print("user = ", e.phase) elseif(e.phase == "editting") then print("user = ", e.phase) elseif(e.phase == "submitted" or e.phase == "ended") then print("user = ", e.phase) native.setKeyboardFocus(passBar) end end local userBar = native.newTextField(w/2, h/2-100, 300, 70) userBar.align = "left" userBar.hasBackground = false userBar.font = native.newFont("Arial", 30) userBar.isFontSizeScaled = true userBar.placeholder = "Username" userBar:setTextColor(255/255, 255/255, 255/255) userBar:setReturnKey("next") userBar:addEventListener("userInput", onUser) -- PASSWORD -- local function onPass(e) if(e.phase == "began") then print("pass = ", e.phase) elseif(e.pahse == "editting") then print("pass = ", e.phase) elseif(e.phase == "submitted" or e.phase == "ended") then print("pass = ", e.phase) native.setKeyboardFocus(nil) end end local passBar = native.newTextField(w/2, h/2+100, 300, 70) passBar.isSecure = true passBar.align = "left" passBar.hasBackground = false passBar.font = native.newFont("Arial", 30) passBar.isFontSizeScaled = true passBar.placeholder = "Password" passBar:setTextColor(255/255, 255/255, 255/255) passBar:setReturnKey("done") passBar:addEventListener("userInput", onPass)
From the logcat, when I pressed the username field, I get
user = began
but when I pressed “next”, I get
user = submitted
user = ended
pass = began
pass = ended
it seemed like I pressed the return button twice. How to fix it?
Thanks
Ming