相关文章推荐
一身肌肉的茄子  ·  react native - ...·  2 年前    · 
一身肌肉的茄子  ·  codenameone - How to ...·  2 年前    · 
一身肌肉的茄子  ·  xcode - iOS build ...·  2 年前    · 
冷冷的板凳  ·  Magic Keyboard with ...·  2 年前    · 
冷冷的板凳  ·  How number matching ...·  2 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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)?

Thanks for your feedback, bit what I’m looking for is not a programmatic solution, but the Done button on (or rather above, in the ios Input Accessory View) the keyboard so the user himself can close the keyboard when done. By the way, I just noticed that there is no Done button shown for a multi-line TextField with normal text, so it seems your documentation is not complete user1246562 Apr 5, 2020 at 7:39

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:

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:

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"):

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.

Thanks a lot for your through answer Francesco and sorry not answering sooner (I haven't build on the device for some time). It is really strange because I now tried adding exactly the same fields you've sown, and I still don't get the Done. I also tried changing the iOS keyboard setting in case that was the reason, no luck. However, I now saw your note above "I just noticed that there is no Done button shown for a multi-line TextField with normal text" which seems to contradict your examples - could you elaborate? – user1246562 May 12, 2020 at 21:27 Coming back to this: what I've seen is that when a TextField is the only input field in a Form the Done button is shown in the iOS virtual keyboard. But if there are other input fields (seems not to matter whether they are before or after the TextField), there is no Done. I cannot find this documented anywhere in CN1 docs and I would really appreciate to understand how to control this (basically force the Done button even if there are other input fields). Anyone suggestions or paths I can explore? – user1246562 May 29, 2020 at 7:02 I have the suspect that your issue is releated to the tabIndex, that is documented here: codenameone.com/blog/right-sidemenu-tab-order.html#_input_cycle So, try to invoke .setTraversable(false) on all your textFields, hopefully every textField will have a Done button. I'm curious to know if it works. – Francesco Galgani May 29, 2020 at 8:25 Thanks again Francesco, very kind of you to provide feedback. I tried that now but it doesn't have a lot of effect (seems setting traversable false simple makes 'next' skip the field). I experimented more, but seem to get all kind of behaviors, depending on I don't know what. I'm a bit tired of spending so much time (since only testable on a device) on what should be straightforward, so I filed an RFE hoping the CN1 team will document how this works: github.com/codenameone/CodenameOne/issues/3126 – user1246562 May 31, 2020 at 19:20

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.