Changes

Jump to navigation Jump to search
290 bytes added ,  11:18, 20 February 2022
fix errors, enhance formatting
==Text Entries==
<context source=yestexcode>
\setupfield[ShortLine][horizontal][width=2cm,height=2em]
\definefield [Email] [line] [ShortLine] [] [sample@contextgarden.net]
\field [Email] [your email]
</contexttexcode>
==Checkboxes==
If you need a lot of similar radiobuttons, like in a questionnaire where you answer every question with a range choice, a meta definition makes sense. Fortunately it’s quite easy:
<texcodecontext source=yes>\setupinteraction[state=start]
\setupfield [ChoiceSetup][width=1em,height=1em,corner=00]
\stoptext
</context>
 
== Fillin fields ==
 
{{cmd|fillinfield}} is meant for clozes (texts with gaps, like in questionnaires) and defined in the {{src|m-fields.mkiv|fields}} module (i.e. you need {{cmd|usemodule|[fields]}}).
 
<texcode>
\fillinfield[name]{text that defines field length}
</texcode>
Disable default validation with {{cmd|setupfieldcategory|2=[fillinfield][validate= Fillin fields ==]}}, because it removes the contents from the field!
These There are meant for clozes (texts some commands with gaps, like in questionnaires); they’re defined a similar purpose in the {{src|mpack-fieldsmrl.mkivmkxl|fieldscore}} module (i.e. you need {{code|\usemodule|[that don’t use fields]}}) and more or less broken (current state unknown).:
* {{cmd|fillinline}}
* {{cmd|fillintext}}
* {{cmd|fillinrules}}
* {{cmd|fillinfield}}
 
<texcode>
\fillinfield[name]{text that defines field length}
</texcode>
Avoid using default validation with {{code|\setupfieldcategory|[fillinfield][validate=]}}, because it removes the contents from the field.
=JavaScript=
If you want to check or otherwise process the input of your forms, you need JavaScript to handle interaction. For simple forms without input validation, you don’t need this.
'''Beware:''' JavaScript in PDFs works only in Adobe Acrobat Reader/Professional (Win/Mac only) and very few other PDF editors, e.g. [[https://www.qoppa.com|Qoppa]]’s PDF Studio (also on Linux) supports JS even in the free viewer, but used to crash on all forms created with TeX in the 2019 version, maybe this is fixed now.
<texcode>
== Documentation ==
JavaScript in Acrobat is different than in a web context. Documentation is even more sparse than on ConTeXt ;).
Debugging is only possible in Acrobat Pro, and also there very inconvenient.
Additionally, Acrobat’s possibilities change with every version.
=Tricks and Traps=
 
==General==
 
* Nothing happens without {{cmd|setupinteraction|2=[state=start]}}! If you need an interactive version and a plain one (e.g. for print), then you must replace your form fields with something else (e.g. {{cmd|framed}}). Use [[Modes]].
==MkIV==
* JS code was only copied to the PDF if there was a {{cmd|goto}} referencing one of the defined functions! – This is actually a feature, you can get your JS without {{cmd|goto}}, using the magic incantation <{{code>|used now</code>}}, as in the default value example. (This was fixed.)
* JS code for default values doesn’t work (reported 2015-04-01, still true 2015-10-07); default values are always used verbatim. (Unchecked if this is fixed.)
* There is no <s>{{cmd|setupfields}} </s> (plural)!
==MkII==

Navigation menu