Expand my Community achievements bar.

setFocus not working in older versions of Reader (pre version 8)

Avatar

Former Community Member
I have a form that was created in LiveCycle Designer 8.2 and has the following issue:



I have used the setFocus method to help the form filler (end user) navigate around the form. It works fine when the end user is viewing the form in Reader version 8 or higher, but it does not work in earlier versions. is there a work around to get similar functionality in earlier versions of Reader.



Example:

there is a drop-down list where the user is directed to different fields depending on their answer. it uses the following if expression in the "validate" event:



if (this.rawValue == 2){

xfa.host.setFocus(textField1);

}



if (this.rawValue == 1) {

xfa.host.setFocus(DropDownList2);

}
8 Replies

Avatar

Former Community Member
The setFocus command has been around for all of that time so I do not think it is that....can you hit Ctrl-J and see if there are any errors in the Java console.

Avatar

Former Community Member
There are no errors in the Java console.



A few weeks back I had a problem (that you helped me with), where the script:



TextField1.caption.font.fill.color.value = "255,0,0";



was changing the color of the font in the text box instead of the caption color, but when you replicated the form, the script worked correctly. I wonder if my "setFocus" problem is another glitch in the software (or at least my installation of the software).

Avatar

Former Community Member
I doubt it ...put an app.alert(this.rawValue) before the if statement to see if you are doing the correct comparison.

Avatar

Level 4
I woud also use the absolute address to make sure you're pointing to the correct fields.

Avatar

Former Community Member
Brian,



I did a couple of test with the setFocus command with these results:



Reader 7.0.5 - setFocus worked if I added somExpression after field:

xfa.host.setFocus(TextField1.somExpression);



Reader 6.0 - setFocus did not work at all even with somExpression and absolute addressing.



Reader 5.0 - Form would not even open. I kept getting the error message "The file is damaged and could not be repaired".



So I added the somExpression as shown and my setFocus works for Reader 7 and up.



Ron

Avatar

Former Community Member
I added an app.alert before the expression, but it just showed that the comparison was correct. I also added the absolute addresses in the expressions, but with the same results.



The somExpression added after the field did correct the problem for Reader 7.0.5, which will cover the majority of the end users, so I will go with that. I am not sure why it is needed, but I am glad it works.



Many thanks to all of you, for your time and assistance.



Brian

Avatar

Former Community Member
Brian,



One more thing about the setFocus issue:



I tried my test form on Adobe Reader 6.0.2 and the setFocus worked OK when using the somExpression.



So adding the somExpression to the setFocus works with Reader 6.0.2 and up, but it did not work with Reader 6.0 or Reader 6.0.1.



LC Designer 8.2 will let you set the minimum target version in the "Form Properties" "Defaults" tab to 6.0.2, so that may be the lowest version it supports. I did notice that at this 6.0.2 version my other Javascript code does not function; not sure why.



Ron

Avatar

Former Community Member
The xfa object model was introduced in 6.02 so anything before that will not work.