setReturnKey("next") works on Android but not iOS. Help!

I’m having trouble getting the keyboard input to move on to the next native text field.  In example:

[User Name]

[Email]

[Password]

This works perfectly on Android. However, it does not work at all on iOS. On iOS the return button does say “Next” with a light background. But it does nothing when you tap on it.

Is there a particular structure required for this to work on iOS? I’ve done a lot of searching and nothing so far. Out of ideas. Has anybody been successful with this?

Hi @infurno,

We likely need to see your code to assist.

Thanks,

Brent

Sure. Very simple:

 nameField = native.newTextField( 0, 0, 200, 50 ); nameField.hasBackground = false; nameField:addEventListener( "userInput", textListener ); nameField:setReturnKey("next"); emailField = native.newTextField( 0, 60, 200, 50 ); emailField.hasBackground = false; emailField:addEventListener( "userInput", textListener ); emailField:setReturnKey("done");

With the silence on the subject I’m guessing that this functionality is either a bug or not supported on iOS? I suppose I’ll submit a bug report next.

Hi @infurno,

Let me do a quick test on this before you file a bug report (if you haven’t already). If I confirm this, then I’ll request you to please file it.

Thanks,

Brent

Hi @infurno,

The engineers report that this is not a bug. Using that function simply sets the name on the “return” key on iOS… it doesn’t inherently do anything else. On Android, it might automatically in some cases (as you see) but not so on iOS. If you want a more reliable cross-platform approach, you should use the “setKeyboardFocus()” function and specify which field it should go to on entering text in the one before, or however you want it to navigate around.

http://docs.coronalabs.com/api/library/native/setKeyboardFocus.html

Take care,

Brent

Thank you for the response. I would suggest that this should be included in the documentation.

Also, if the native Android Next functionality works in some cases then it may result in a race condition and conflict with setKeyboardFocus. I haven’t confirmed this, but it does seem likely.

Hi @infurno,

Good to hear it’s working. I will note to add this detail to the documentation.

As for the Android thing, I suspect that if the OS is trying to automatically push the focus to the “next” field, but then you call Corona to put the focus on a specific field, it will override the OS and put it in the proper place. However, if you can confirm that this causes a race condition, please report it so that we can investigate further.

Thanks,

Brent

Hi @infurno,

We likely need to see your code to assist.

Thanks,

Brent

Sure. Very simple:

 nameField = native.newTextField( 0, 0, 200, 50 ); nameField.hasBackground = false; nameField:addEventListener( "userInput", textListener ); nameField:setReturnKey("next"); emailField = native.newTextField( 0, 60, 200, 50 ); emailField.hasBackground = false; emailField:addEventListener( "userInput", textListener ); emailField:setReturnKey("done");

With the silence on the subject I’m guessing that this functionality is either a bug or not supported on iOS? I suppose I’ll submit a bug report next.

Hi @infurno,

Let me do a quick test on this before you file a bug report (if you haven’t already). If I confirm this, then I’ll request you to please file it.

Thanks,

Brent

Hi @infurno,

The engineers report that this is not a bug. Using that function simply sets the name on the “return” key on iOS… it doesn’t inherently do anything else. On Android, it might automatically in some cases (as you see) but not so on iOS. If you want a more reliable cross-platform approach, you should use the “setKeyboardFocus()” function and specify which field it should go to on entering text in the one before, or however you want it to navigate around.

http://docs.coronalabs.com/api/library/native/setKeyboardFocus.html

Take care,

Brent

Thank you for the response. I would suggest that this should be included in the documentation.

Also, if the native Android Next functionality works in some cases then it may result in a race condition and conflict with setKeyboardFocus. I haven’t confirmed this, but it does seem likely.

Hi @infurno,

Good to hear it’s working. I will note to add this detail to the documentation.

As for the Android thing, I suspect that if the OS is trying to automatically push the focus to the “next” field, but then you call Corona to put the focus on a specific field, it will override the OS and put it in the proper place. However, if you can confirm that this causes a race condition, please report it so that we can investigate further.

Thanks,

Brent