Enter key to be treated as Tab key and move to the next field.

Avatar

Avatar

_SekharN_

Avatar

_SekharN_

_SekharN_

05-04-2006

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?

Replies

Avatar

05-04-2006

Fortunately, hitting the [Enter] key causes a field's Exit event to be executed. This means that while you can't get Acrobat to automatically set focus to the next field in tab order when the user presses the [Enter] key, you can use JavaScript to set focus to the field which
you know is next in tab order.



All you need to do is place the following JavaScript code in a field's Exit event to have focus move to another field:



xfa.host.setFocus("
FieldName");


(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.



Stefan

Adobe Systems

Avatar

Avatar

_SekharN_

Avatar

_SekharN_

_SekharN_

06-04-2006

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[0].NextField)) then

//when focus is setfrom a field and next field name is added as text.

var TabTo

TabTo = form1.#subform[0].NextField.value.#text

form1.#subform[0].NextField.value.#text = ""

//clear the field text, it is one time use only.

xfa.host.setFocus(TabTo)

//sets focus to the field you passed.

else

//when user manually tabs into this field focus needs to set

//to default object

xfa.host.setFocus("form1.#subform[0].Button1")

endif