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

Wait function in custom format script

GlennOwns
Registered: Jun 30 2010
Posts: 18
Answered

Here is my code:
 
if(event.commitKey !=0){this.getField('nextField').setFocus();}
  
How do i make it delay/wait for 1 second before moving to the next field?
I use a scanner that takes a barcode and inputs the return key after the barcode is inputted, however the return key sometimes beats the entire barcode, so the barcode is cut off...
 
I was wondering if there was a way to delay this a second?

My Product Information:
Acrobat Pro, Windows
George_Johnson
Online
Expert
Registered: Jul 6 2008
Posts: 1876
Accepted Answer
You could try the app.setTimeout method:

  1. if(event.commitKey != 0) {
  2. app.setTimeOut("this.getField(\'nextField\').setFocus();", 1000);
  3. }
GlennOwns
Registered: Jun 30 2010
Posts: 18
George, that works wonderfully!

Now I got a dumb problem.. When I reset the form's field (through regular Acrobat Reset button), it focuses on random fields... I think it has something to do with the event.commitKey line.. I will be copying it 20 times in 20 different fields (of course with 20 different setFocus's.

So, how do i make the event happen ONLY on the enter key? I tried onKey, commitKey, charCode, etc..

Thanks in advanced.. this is kickin my butt right now..
George_Johnson
Online
Expert
Registered: Jul 6 2008
Posts: 1876
Try:

  1. if (event.commitKey === 2) {