Frequently Asked Questions

It’s Wednesday and time for another FAQ session. Here are five frequently asked questions (FAQ).

1. Why is the “submitted” event phase missing for native.newTextField on devices but it’s working on the Mac Simulator?

The “submitted” phase is sent when the user presses the “return” or “done” key on the keyboard. It’s intended to indicate that the user has finished text entry and “submitted” the information. It will not be sent if the user changes focus by clicking on a different field. Before build 904, the Mac Simulator always sent the “submitted” and “ended” phases together (even when the submitted key was not clicked). Starting with build 904, the Mac Simulator now works in a similar way to how iOS and Android works.

2. I’m confused about the “ended” and “submitted” phases for native.newTextFields.

Here is a summary of how TextField events works. When the user touches/clicks on a TextField, the “began” phase is sent and the keyboard is visible. Typing generates the “editing” phase. If the return/done button is clicked, a “submitted” phase is sent followed by the “ended” phase. If the user touches another TextField (or TextBox), the “ended” phase is sent (without the “submitted” phase).

On iOS if you create a TextField for numbers, the number keyboard does not have a return key to end the input so you need to provide a button that the user presses when done. You would call native.setKeyboardFocus with nil to hide the keyboard. Hiding the keyboard will generate an “ended” phase for that TextField object.

Note: What I described above only works on the Mac Simulator starting with build 904.

3. What happened to the “submitted” event phase on native.newTextBox?

There is no submitted event phase with newTextBox. The reason is the return key generates a new line instead of submitting the content of what was entered. As mentioned in the previous question, you need to create a button that the user can press when they are finished.

4. When using native.newTextField, how do I hide the keyboard?

To hide the keyboard on either native.newTextField or native.newTextBox, call native.setKeyboardFocus with nil. Conversely, you can set focus on either type of native text objects by calling native.setKeyboardFocus with the text object’s handle.

5. How can I edit text in the native.newTextBox?

By default the native.newTextBox is not editable. You can enable the edit mode by setting object.isEditable = true (where “object” is the native.newTextBox handle).

That’s it for today’s questions. I hope you enjoyed it and even learned a few things.

  1. The “submitted” phase is sent when the user presses the “return” or “done” key on the keyboard. It’s intended to indicate that the user has finished text entry and “submitted” the information. It will not be sent if the user changes focus by clicking on a different field. Before build 904, the Mac Simulator always sent the “submitted” and “ended” phases together (even when the submitted key was not clicked). Starting with build 904, the Mac Simulator now works in a similar way to how iOS and Android works.

  2. When I type in a text field in non-English (e.g. Korean), Corona processes it as just a set of question marks (i.e. ???…). What should I do to make it compatible with non-English characters?

  3. I just took a quick glance at CoronaLabs’ roadmap but supporting native text inputs in the Windows simulator is not mentioned anywhere. Does this mean it is never going to happen? That’ll be somewhat of a show stopper for me….

  4. Please please give us a status update on windows simulator support for these features. This is such a basic feature I can’t believe its not possible for me to do this on windows. Ok, maps I understand is more complex… but a text box?

    The apps I was going to create are going to be a nightmare to make without this support.

  5. We understand that the lack of native widgets is frustrating but Windows doesn’t permit mixing of native objects and OpenGL surfaces in a way that is useful. We’re looking at alternative solutions but I don’t have an ETA for anything at the moment.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>