It’s time for another FAQ session! Here are some frequently asked questions:

1. How do the “ended” and “submitted” phases work for native.newTextField() objects?

Here is a summary of how native.newTextField() events works:

  • When the user touches/clicks on the field, the "began" phase occurs and, on mobile devices, the virtual keyboard becomes visible.
  • Typing generates the "editing" phase.
  • If the return/done button is clicked, a "submitted" phase occurs concurrently with an "ended" phase. However, If the user touches a different text field/box, the "ended" phase occurs without the "submitted" phase. Essentially, the "submitted" phase occurs when the user presses the return/done key on the keyboard. It’s intended to indicate that the user has finished text entry and “submitted” the information.
  • On iOS, if you create a text field restricted to numeric input, the numeric keyboard does not have a return/done key to end its input, so you need to provide a standard button or some other means to tell the system that the user has finished entering numbers. At this point, you should call native.setKeyboardFocus() with nil to hide the keyboard which will generate an "ended" phase for the text field object.

2. What happened to the “submitted” event phase for native.newTextBox()?

There is no "submitted" event phase for native.newTextBox() objects. This is because the return/done key generates a new line instead of submitting the content of what was entered. As mentioned in the previous question, you should create a button or other means to indicate that the user has finished entering text.

3. When using native input fields/boxes, how do I hide the keyboard?

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

4. How can I edit text within a native.newTextBox()?

By default, the text within a native.newTextBox() object is not editable. However, you can easily enable the edit mode by setting object.isEditable to true, where object is the native.newTextBox() object’s handle.

  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=""> <s> <strike> <strong>