PDF-Forms is a service provided by PDFzone.com | http://www.pdfzone.com/ __________________________________________________________________
This comes from a recharged Sunday brain...
First, it is not really a good idea to do this in the Keystroke event, because it would not handle the case when the field gets reset (when you reset, there is not really a Keystroke event). Instead of that, do it in the Validate event.
Second, in order to keep this code a bit more reusable, it is better to not hardwire the field name, but use event.target instead (event.target is -- for fields -- the Field object in which the "action" goes). And for reusability, the whole thing gets into a function.
Third, in order to properly handle resets and users deleting the field's contents, an empty field should show a transparent background. (this approach would then allow the form to be used as a dumb Level 0 form (print out and fill out), besides being used at higher levels.)
So, the result would be as follows:
On document level (preferrably), define the following function:
function showMulti()
{
var a = event.target ;
if (event.value != "") {
a.fillColor = color.white;
a.borderStyle = border.s;
a.lineWidth = 1;
a.strokeColor = color.black;
} else {
a.fillColor = color.transparent;
a.borderStyle = border.s;
a.lineWidth = 1;
a.strokeColor = color.transparent;
} ;
}Then, in each of the fields which should get this treatment, you assign to the Validate event:
showMulti() ;
And that should do it.
You could also put this into the Format event, BTW.
Hope, this can help.
Max Wyss PRODOK Engineering Low Paper workflows, Smart documents, PDF forms CH-8906 Bonstetten, Switzerland
Fax: +41 1 700 20 37 or +1 815 425 6566 e-mail: mailto:[EMAIL PROTECTED] http://www.prodok.com
[ Building Bridges for Information ]
______________________
Shameless Plug:
My next conference appearances and workshops:
• Training classes in cooperation with essociates Group, in Toronto, ON, Canada, March 9 - 12, 2004; more information at http://www.essociatesgroup.com/AdvancedAcrobatForms.htm and http://www.essociatesgroup.com/MultipleLanguageFormsInAcrobat.htm
• And, as always, available for on-site workshops/tutorials/consulting.
_________________________
Could somebody please help my poor, useless friday afternoon brain out?
Intended result:
The user enters a multi-line field. Because the artwork behind the field has lines and Acrobat will not allow us to set lineSpacing values, I want the field to cover the artwork behind it (seemingly erasing the lines) when the user starts entering data. If they tab out again without typing anything - no effect. They start typing, launch this:
var a = this.getField('1.describe');
a.fillColor = color.white;
a.borderStyle = border.s;
a.lineWidth = 1;
a.strokeColor = color.black;
So I put the above code into the Keystroke action but it doesn't fire. I put it (with conditional logic) into the onBlur action and the script does work as I intended, just not at the appropriate time.
I remember hearing something about restrictions in Keystroke scripts but I can't remember now what they were. Is it possible to run this script on the first keystroke?
To change your subscription: http://www.pdfzone.com/discussions/lists-pdfforms.html
