I have a requirement to do the following in a PDF form designed in LiveCycle 7: When a user clicks on Enter key that have to be treated as Tab key and move the curser to the next Text field available.
Can any one help me how to achieve with an example?
(Note that you would replace FieldName with the name of the field which should receive focus.)
The key here is to replicate your form's tab order by using this script in each field's Exit event so that as the user hits the [Enter] key, focus moves to the next field in tab order (and they can still use the tab key if they want to -- just make sure you keep the form's tab order in sync with the sequence of xfa.host.setFocus calls).
I've attached a form with 3 text fields. Their tab order is set in the order that they're numbered (1 - top, 2 - bottom, 3 - middle). Check-out the script in their Exit events.
Thank you Stefan, I used exactly the same principle to get this working. I thought there will be an easy way to do this by changing some environmental setting.
In my case I added an additional dummy textfield and in the Exit event of the each field I set the focus to dummy and write the name of the field that the focus needs to go to when they hit [Enter].
And then I used following code to set the focus to the field I want to set to. Which is more helpful in my case as I need confirm messages based on input value and "Yes" or "No" selection. Also I matched the sequence of Tabbing order as you said.
if (HasValue(form1.#subform.NextField)) then
//when focus is setfrom a field and next field name is added as text.
TabTo = form1.#subform.NextField.value.#text
form1.#subform.NextField.value.#text = ""
//clear the field text, it is one time use only.
//sets focus to the field you passed.
//when user manually tabs into this field focus needs to set