native.newTextField calls event.phase == "submitted" twice?

I ran into this problem as well.

This is definitely a bug , I’m a bit disappointed in the Corona team for repeatedly telling users to use the sample code. 

The very fact that “submitted” occurs twice, and “ended” occurs once, indicates that the listener isn’t installed twice, as in that case you would get an even number of both events.  

For me, it’s happening on a Samsung Galaxy Tab 4.

Much thanks to Robert Phillips who pointed out the problem only occurs when you choose something other than “done” for the return key value. 

I was using “go” and “search” for return key values – switching back to “done” resolved the issue. 

Hi @charles.l.capps,

Thanks for detailing this. Can you please file a bug report so we have it logged in our system? Please include a very basic sample project along with the bug report (you may be able to modify our “Interface>NativeKeyboard” sample for it).

When the bug is filed, please post back with the case # here for reference.

Thanks,

Brent

Sure, I’ll file a bug tonight when I’m not at work. 

I’ll create a minimal sample project that reproduces the issue. 

Sorry about my being a bit critical, I realize the sample code a user submitted doesn’t include the call to “myTextField:setReturnKey(‘go’)” which is needed for the bug to occur.

Thanks Charles, and we appreciate it. It’s fine to be “critical” about a legitimate bug. :slight_smile:

Brent

Okay, I submitted a bug including the minimal code needed to reproduce, and exact steps. 

FYI, this happens on my Galaxy S5 smartphone, as well as on my Galaxy Tab 4. 

It’s possible it affects all Android devices, or all Samsung devices, but I obviously can’t infer that without buying all the devices in the world  :slight_smile:

Thanks for looking into this – this bug is forcing me to use the “done” key on all of my native inputs. Which is a bit sad, since I’d like to use the search icon in a few places, and the “go” key in another place.

Cheers! 

You should have received an email that had a Case Number in it. Please post that case # here for reference.

Thanks

Rob

Charles,

I ran into this issue it appears in April and had to implement a boolean to work around the issue. You can do this dirty method, or hold off until the bug if fixed. I ended up getting too frustrated and decided to write my code in Java. Good luck! 

I do love the little amount of code required with Corona, but unless I’m making a game I probably will just write my code in native code. After I finish this social based app I plan on making a game  :wink:

Justin

Yes, I could have a boolean keeping track of whether a submission is in progress (in my case, doing an HTTP request, validating the response, then loading a new scene with composer or displaying an error message.) 

However, having this extra state is extra complexity, and this boolean must be reset to false after every possible way for the triggered code to succeed or fail (otherwise, the keyboard would stop working! ). 

TL; DR - I decided it’s best to just use the “done” return key rather than add new failure points and poor software engineering to my code just to work around the bug. 

So, I’ll be happy when it’s fixed. 

Makes sense. Just stating it CAN be done, but will be extremely ugly. I couldn’t imagine this bug being too difficult to resolve, but who knows.

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

What happens if you don’t set… :setReturnKey()?

Rob

Rob, it appears to have the same outcome…

Ming

Any solutions, Rob?

Thanks in advance.

Ming