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?