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

Select contents of a field on enter

Hammo
Registered: Aug 22 2007
Posts: 2

I am using LiveCycle Designer 8.1. I am trying to do something that should be very simple. When a user enters a field I would like the entire contents of the field to be automatically selected. I have messed around with selStart and selEnd and had no luck.

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The selStart and selEnd event properties are only valid for the change event, i.e. when the user is entering text. I believe you are trying to capture the moment when the field acquires the focus.

This situation is not a simple as one might think. If the user tabs into the field the contents should automatically be highlighted. If the user clicks in to the field with the mouse, the cusor is placed at the location of the click. It's this second situation that needs to be handled, and unforturnately there is no built in support for doing it. You're going to have to be creative.

Here's one technique. Use the Enter event to reset the field focus to another field. Then use that field's Enter event to set the focus back to the original field. These actions guarentee that the field always recieves a kind of forced tabbing, and that the contents are always selected.

Be warned, this is tricky business. You need to build a kind of state machine that keeps track of the sequence of events. Otherwise you'll be creating an endless loop. The user should also not be aware of the second field. It should be very small, with no borders, caption, or background, and be located at the edge of the document where the user won't be clicking.

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