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

Selecting the end of the text in a field

Grika
Registered: Dec 9 2009
Posts: 35

I need to be able to take the user to a certain field to enter text but if there is already text in the field, they need to be able to just start typing, adding to that text without wiping out what's there.

I know I can use setFocus to get to a field, but the entire contents of that field are then selected which get replaced when the user starts typing.

My Product Information:
Acrobat Pro 8.1.7
try67
Online
Expert
Registered: Oct 30 2008
Posts: 2399
The event object has a selStart and a selEnd properties that give the position of the selection on a keystroke, but I don't think they can be used for what you describe. You can give it a try, though.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
This is a tricky one. You'll need a custom keystroke script on the destination field, all the data you need to allow the user to just start typing is there. First though, you'll need to add code to the script that runs "setFocus" to also set a document level variable so the keystroke script can detect the situation where it needs to restore the field value. The keystroke script then uses the "event.value" property to restore the previous field data when the user types the first character.

something like this:

if(bRestoreData)
event.change = event.value + event.change;

To be more complete you could use the event.selStart and event.selEnd to do an exact restoration.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

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