TextBox not firing "ended" and "submitted" events on iOS

I took the code from the documentation for TextBox and simplified it to it’s bare minimum.

On the simulator it works as expected but on the device (iOS 9.3) the only events fired are “began” and “editing”. None of the other events are fired.

What I’m looking for is a way to catch the “ended” or “submitted” event when the user hits the “Done” key. 

local defaultBox local function textListener( event ) print( event.phase ) if ( event.phase == "ended" or event.phase == "submitted" ) then native.setKeyboardFocus( nil ) end end -- Create text box defaultBox = native.newTextBox( 200, 200, 280, 140 ) defaultBox.text = "Test" defaultBox.isEditable = true defaultBox:setReturnKey("done") defaultBox:addEventListener( "userInput", textListener )

I suppose I could analyze the text and see if the last character is a newline and act accordingly but that seems like it can break easily with different devices using different characters (\n or \r) for new lines.

I would love to be able to use the Corona events. Is that possible with a native.TextBox object?

I would confirm the version and then check a previous daily build and the current stable to make sure it is working there. The example you provide matches the functionality in the docs, so it might be a regression which wasn’t caught in testing.

I just built this example with the latest daily build and also with the latest current stable version and I get exactly the same results when running on iOS. Still, submitted and ended events aren’t being fired.

Latest daily build:

iPhone / iPhone8,2 / 9.3.2 / Apple A9 GPU / OpenGL ES 2.0 Apple A9 GPU - 77.14 / 2016.2907 / en-US | US | en_US | en

Latest stable version:

iPhone / iPhone8,2 / 9.3.2 / Apple A9 GPU / OpenGL ES 2.0 Apple A9 GPU - 77.14 / 2016.2830 / en-US | US | en_US | en

Here’s what the Corona support guys said:

Hello,

Thanks for submitting the bug. Text boxes are designed for entering multiple lines so the return key always inserts a new line. The fact that you can change the name of the return key seems like a bug because it really doesn’t change the behavior of the key in text boxes. If you want a Done button and have it trigger a submit event, you should really use text fields instead.

The ended phase on a text box does occur when the keyboard is dismissed which can be done on an iPad device. The general practice for text boxes is to add your own “Done” button near the text box that the user can press when done entering text.

We need to clean up our documentation on native.newTextBox to indicate these facts.

Makes sense. I’ll be off to adding my own “Done” button!

I would confirm the version and then check a previous daily build and the current stable to make sure it is working there. The example you provide matches the functionality in the docs, so it might be a regression which wasn’t caught in testing.

I just built this example with the latest daily build and also with the latest current stable version and I get exactly the same results when running on iOS. Still, submitted and ended events aren’t being fired.

Latest daily build:

iPhone / iPhone8,2 / 9.3.2 / Apple A9 GPU / OpenGL ES 2.0 Apple A9 GPU - 77.14 / 2016.2907 / en-US | US | en_US | en

Latest stable version:

iPhone / iPhone8,2 / 9.3.2 / Apple A9 GPU / OpenGL ES 2.0 Apple A9 GPU - 77.14 / 2016.2830 / en-US | US | en_US | en

Here’s what the Corona support guys said:

Hello,

Thanks for submitting the bug. Text boxes are designed for entering multiple lines so the return key always inserts a new line. The fact that you can change the name of the return key seems like a bug because it really doesn’t change the behavior of the key in text boxes. If you want a Done button and have it trigger a submit event, you should really use text fields instead.

The ended phase on a text box does occur when the keyboard is dismissed which can be done on an iPad device. The general practice for text boxes is to add your own “Done” button near the text box that the user can press when done entering text.

We need to clean up our documentation on native.newTextBox to indicate these facts.

Makes sense. I’ll be off to adding my own “Done” button!