These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

OCGs and Combo Boxes

AndrewAlb
Registered: Aug 16 2007
Posts: 97

I am trying to use a combo box to control the layers (OCG's) in my acrobat form. Using the mouse it works perfectly fine. However, I want my users to be able to use only the keyboard if they desire. That is, use their up/down arrows to select the combo box value and then tab off and continue. For some reason when I change the layers visibility property it messes with my combo box and I can't use my keyboard to make the selection (again it works fine when using the mouse). Is there something going on behind the scenes that I don't know about - some reset command or something?. Or is my changeEx and incorrect method for this approach? Any insight would be appreciated.
Here is my code:
 
if (event.changeEx == "A")
{
ocgs[2].state = false
ocgs[3].state = false
ocgs[4].state = true
ocgs[5].state = false
}
else if (event.changeEx == "B")
{
ocgs[2].state = true
ocgs[3].state = false
ocgs[4].state = false
ocgs[5].state = false
}
  
else if (event.changeEx == "C")
{
ocgs[2].state = true
ocgs[3].state = true
ocgs[4].state = false
ocgs[5].state = false
}
else if (event.changeEx == "D")
{
ocgs[2].state = false
ocgs[3].state = false
ocgs[4].state = false
ocgs[5].state = true
};

Andrew D. Albrecht, MS
Solutions Developer
ING USFS

My Product Information:
Acrobat Pro 8, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Changing the OCG state causes the page to re-render, which is probably changing the field focus.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

dzurn
Registered: Aug 24 2006
Posts: 4
You can specify which field to focus on. I have a custom validation script that corrects user input, and I have this at the end to keep focus so the user can fix their input:

event.target.setFocus();Works great.