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

Identifying which form field has 'got focus' (via acrobat, designer or reader)

Celticbluestone
Registered: May 13 2011
Posts: 4

Help!
Trying to add a button to a PDF form that needs to be able to identify which field on the form has 'got focus' and to use this to initiate a java script action that will use the 'got focus' field name as part of the script action. I am assuming that the button will have to be added to a toolbar since a button on the form will move the focus from the field in focus to the button itself. Any of you gurus out there managed to achieve this or is this not achievable? Any help or guidance on this would be hugely appreciated!

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
You might want to look at the Acrobat JavaScript API Reference and the section about form fields and the event processing within a form field.

If you click on a button, then that button field obtains the focus. If you want to known within a script which form field has focus, you can use the 'event.target.name' method, but for folder level scripts you will need to pass the current 'doc' object an the current field object as parameters to the function.

George Kaiser

George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
There is nothing that can tell you which field currently has the focus, and it's possible that none do. You could place code in the On Focus/On Blur events of each field you're concerned with that updates some variable, and attempt to deduce which field has or last had the focus.

But what you're describing may not be the best approach. If you provide more details about what your goal is, someone might be able to suggest something else.
Celticbluestone
Registered: May 13 2011
Posts: 4
Thank you both for your prompt replies. I am looking to create a PDF form that Users will use to enter data extracted from historical paper records. As this entry progresses the user might not be able to interpret the paper record for a field to be entered. While this field on the PDF form has got focus I would like the user to be able to press a button that will trigger a question form process to be triggered that will then route this question back to the paper form originator to resolve the question. So ideally I would like this question process to be initiated while the field that is being questioned has the form entry focus. By pressing a 'raise a question' button I would like the script behind the bottom to able to programmatically read the field name that has focus on the entry form and to pass this Id to the question form which will then be routed to the originator for question resolution.

Since the user might need to raise a question against any of the many fields on the PDF form then the button a script would ideally be portioned on a toolbar so that it is always visible at the top/side of the form agent presented in reader. I hope this help explain what I am trying to achieve. Will the event.target.name enable me to achieve this and if so can this be used in a toolbar button script? I am new to the adobe environment so any suggestions, pointers or code examples would greatly appreciated. Many thanks, Michael.

George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
event.target will identify the field to which a script is attached, so it won't work for what you're wanting to do. I think my previous suggestion is the closest you can get if you want to do this from a single control (form button or toolbar button). As you mentioned, when you click a button on the page or a toolbar, a field that previously had the focus will lose it, so the best you can do is explicitly keep track of which field last received/lost the focus.
Celticbluestone
Registered: May 13 2011
Posts: 4
Thank you both..will look at your suggestions this week. As an aside, while looking for a solution to this I came across a plugin Acrobuttons, have either of you used or know of this?
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
AcroButtons is great.