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

Help needed on the implementation <Insert mode> on text field

MDA
Registered: Feb 1 2010
Posts: 16
Answered

In MS Word, there is a way to input with the insert mode (just press the Insert key on the keyboard). Is it possible to do it in the text field?

I have tried to implement it in the Custom Keystroke by some events. But all was failed. I am wondering if it is impossible.

I thought this may be a common issue, but I can't find any postings about this.

Thanks in advance,

Eugene

My Product Information:
Acrobat Pro 9.2, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
In Word, and many other text entry applications, the insert key toggles between "Insert" and "Overwrite" mode. In an Acrobat text field there is only insert mode.

Is this what you are getting at. If not then please explain more.

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

MDA
Registered: Feb 1 2010
Posts: 16
Thanks THOMP. Sorry for the misunderstanding question. I need the "Overwrite" mode solution.

I am appreciated if you have any idea to implement it in Adobe Pro.

Eugene
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You could in fact used the keystroke event to implement a psuedo-overwrite mode. But this is tricky business. The script has to examine and modify "event.selEnd" and "event.selStart".

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

MDA
Registered: Feb 1 2010
Posts: 16
Thanks for the fast response. I do can get the correct string in keystroke event by event.change, changeEx, selStart and selEnd. Then put the new string to another text field and setFocus to the new field, then send the string back to the original field by calculate event. The problem is the cursor location is missing in the original field.

I thought it is common issue for the pdf user, but when I spent couple of hours doing it, I found it is not easy or may be it is impossible to do this way.

Thanks again,

Eugene
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Actually it's much easier than that. All you have to do is to increment "selEnd" when "selEnd == selStart" and the cursor is not at the end of the entry.

This script works:
if(!event.willCommit){var curLen = event.value.length;if(curLen && (event.selStart != curLen) && (event.selEnd == event.selStart) )event.selEnd++;}

Of course it sets the field to overwrite mode all the time. You may want to put a qualifier in there to turn it on and off.

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

MDA
Registered: Feb 1 2010
Posts: 16
Thanks Thomp, it is what I am looking for. I am very appreciated your helps.

Eugene
MDA
Registered: Feb 1 2010
Posts: 16
Here is the latest code considering copy/paste:

//Set maxLength to the fixed size length for the text field// otherwise set it to -1 function overWriteMode(event, maxLength){if(!event.willCommit){var curLen = event.value.length;if(curLen && (event.selStart != curLen) && (event.selEnd == event.selStart) ){if(event.fieldFull){var exValue = event.changeEx;if( maxLength >	event.selStart)event.change =exValue.substring(0, maxLength - event.selStart);elseevent.change =exValue;}var c = event.change;event.selEnd = event.selEnd+ c.length;}} }  Call the method from Custom Keystroke Script:  overWriteMode(event, 10);        <-----  10 characters limited in the text field overWriteMode(event, -1);        <-----   No limit