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

Text Flow/Backspace Script for Multiple Text Fields

MrChinhNguyen
Registered: Dec 19 2007
Posts: 9

I currently have a question with 2 dedicated text fields (view example below)

Question? _______________________ <(Comments.1)
_______________________________ <(Comments.2)

I need to be able to type into Comments.1 and have the text flow into Comments.2 and also have the ability to backspace back into Comments.1.

I was able to setup text flow from Comments.1 to Comments.2 with the scripting below placed into the Keystroke Script field for Comments.1's Format Properties.

if(event.fieldFull)
this.getField("Comments.2").setFocus();

But I am unable to backspace from Comments.2 to Comments.1.
Does anyone know the script? Thanks in advance for the help!

My Product Information:
Acrobat Pro 8.1.2, Macintosh
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Automatically moving between fields can be problematic because Acrobat JavaScript does not provide all of the events you need to do this cleanly. However, if all you want to do is detect when the second field has been emptied with a backspace or delete operation, then use a keystroke event in the second field.

Use the selection, change, and value properties of the event object to build the new text string that will be entered on completion of the event. If the string is empty, move focus to the previous field.

Unfortunately you cannot easily detect the situation where both fields contain data and characters are removed from the first field. In this situation you might want to transfer characters from the second field to the first, making both fields look and behave as one field. Depending on how far you want to take this, it can get messy.

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