Make cursor active in prompt box

The following script snippet presents a text box for independent capture of a text field. This is part of longer script to save individual reminders while in a draft.

The script works, though when the prompt dialog presents, I have to tap in the text box to enable editing. Ideally, when the prompt shows, the editor would be ready to accept input without tapping in the text box.

Is this a configurable option/parameter? Thanks for guidance

var p = Prompt.create();
p.title = "To Do";
p.addTextView("todoText","","");
p.addButton("Save");
if (p.show()) {
  alert(p.fieldValues["todoText"]);
}
editor.activate();

There’s no parameter to cause a field to be automatically focused (yet), but the fields in a prompt do respond to the keyboard: press the down-arrow to cycle through each field or button, and press the Return key to activate or press.

1 Like

Thanks for your response to the question.

The keyboard keys do allow me to move between buttons, but I’m not able to activate the cursor in the text field from the keyboard. Or, I’m not pressing the right key.

It’s not visually obvious, but as soon as you press up-arrow or down-arrow, the selected field looks normal, and the rest are dimmed. So if the text field is the first field in the prompt, when it appears, you literally just press down then Return. The text field will then be focused, with the insertion-point etc.

Try it.

3 Likes

ok… figured it out thanks to your comments. Still wasn’t working, so looked at code again. Switched from p.addTextView to p.addTextField. Silly mistake but I was duped because p.addTextView was (mostly) working!

1 Like