Expand my Community achievements bar.

unable to use the focus feature on a field

Avatar

Former Community Member
hi,



I have the need to manipulate the focus event of a field. This is my pdf body structure :



form1 ----> form

|_ a ----> page

|_b ----> textfield

|_c ----> textfield



The idea is to test if the user pressed the key "ESC", "TAB" or "ENTER" when exiting from field "b". If so, and after testing the content of the field, i wanted to set the focus on that same field "b" to let the user proceed with the correction.



I tried with the "xfa.event.commitKey" to see if the "ESC", "TAB" or "ENTER" keys where pressed while exiting the field. I then redirected the focus to different fields named "ESC", "TAB" and "ENTER" just to be sure that i was getting the correct keys.



This feature works if i set the focus in a different field than the one i'm exiting.



Then, i tried a different approach. On the exit event of the field, i placed the following code :



app.setTimeOut("this.getField('form1[0].a[0].b[0]').setFocus()", 1000);



This would do the same as the setFocus after a while.



For what i could see, catching the events with the "xfa.event.commitKey" for the "ESC", "TAB" or "ENTER" key works alright. The problem is to set the focus to the current field ( the one where the exit event is being analyzed ). However, if i change the destination field to any other field on the form, all the scripts work.



Following the structure that i have on top, it the exit event is being analyzed on field "b" and the "setFocus" or the "app.setTimeOut" scripts indicate field "b" as destination, it doesn't work.

If i change the destination field to be "c", all the scripts work as expected. It seems like there is a problem with setting the focus on the field that i'm exiting from.



Any ideas on this ???



Thanks.
1 Reply

Avatar

Former Community Member
Does anyone have a solution to this problem?

I'm urgently trying to find a workaround, but nothing seems to work.

The focus on the current field works in acrobat reader versions above 8.0, but in 8.0 it just doesn''t work...



To reiterate:



On the exit event of a textbox I need to display a validation message if a certain condition is met. I then need to refocus on the same textbox after the "ok" button is clicked in the validation warning.



My setFocus code is correct, but it just doesn't work in 8.0.



Thoughts?