How to close a TextField numeric keyboard on iOS after editing?

Viewed 176

I would like to edit a numeric decimal value like 21.7 and enable the user to close the numeric keyboard (iOS 13.3.1, iPhone Xr) when done.

I'm using a numeric text field (TextField with constraint TextArea.DECIMAL). I've NOT set the option putClientProperty("iosHideToolbar", Boolean.TURE) for the TextField. However, there is no keyboard Done option, so the user cannot close the keyboard after entering the value.

I've gone through the documentation (https://www.codenameone.com/manual/components.html) and as I understood it, using tf.putClientProperty("iosHideToolbar", Boolean.TRUE); would hide the toolbar, so since I'm NOT setting the property, I assume the toolbar and the Done button should be available.

Any advice on how to get the Done button (or other ways to getting rid of the numeric keyboard)?

2 Answers

In the action listener for the text field you can just invoke stopEditing() on the text field. You can use either the standard action listener or the done listener for this purpose.

I would like to edit a numeric decimal value like 21.7 and enable the user to close the numeric keyboard (iOS 13.3.1, iPhone Xr) when done.

I'm using a numeric text field (TextField with constraint TextArea.DECIMAL). I've NOT set the option putClientProperty("iosHideToolbar", Boolean.TURE) for the TextField. However, there is no keyboard Done option, so the user cannot close the keyboard after entering the value.

Are you sure?

I tried the following code on iOS 13 (iPhone X):

Form hi = new Form("Example", BoxLayout.y());
hi.add("Enter a decimal value:");
TextField textField = new TextField();
textField.setConstraint(TextArea.DECIMAL);
hi.add(textField);
hi.add(new Button("Submit"));
hi.show();

Result:

enter image description here

As you can see, this sample code produces the "Done" button on iOS. So, if your app doesn't show it, maybe the cause of the issue is elsewhere.

I just noticed that there is no Done button shown for a multi-line TextField with normal text

I tried:

Form hi = new Form("Example", BoxLayout.y());
hi.add("Enter a multiline text:");
TextArea textField = new TextArea("", 3, 80);
textField.setConstraint(TextArea.ANY);
hi.add(textField);
hi.add(new Button("Submit"));
hi.show();

Result:

enter image description here

Also in this case, there is the "Done" button.

Currently, as far as I know, the "Done" button is not shown in the iOS virtual keyboard toolbar if it's already included in the keyboard itself, for example in the case of a generic TextField without a "next" TextField. I mean like in the following screenshot (note that the blue key "fine" is the Italian equivalent of "Done"):

enter image description here

So, I don't know how to help you. Try to update your question (or try to open a new one) adding a self-enclosed test case that reproduces your issue.

Related