Changes

Jump to navigation Jump to search
55 bytes removed ,  10:06, 7 October 2015
explain JS in PDF without goto
You can find more about interactive form elements in [http://www.pragma-ade.com/general/manuals/mwidget-s.pdf Widgets uncovered]. It’s written for MkII, but still mostly valid.
At the moment all Most of the following examples are from <tt>mwidget</tt> manual. We will cook up our own later.
=JavaScript=
== Documentation ==
JavaScript in Acrobat is different than in a web context. Documentation is even more sparse that than on ConTeXt ;)
Debugging is only possible in Acrobat Pro, and also there very inconvenient.
Additionally, Acrobat’s possibilities change with every version.
\setupinteraction [state=start]
\startJSpreamble {EXAMPLE}used now
var d = new Date();
var df = this.getField("CurDate");
}
\stopJSpreamble
 
% this button makes no sense for the example, but in MkIV we need one \goto,
% otherwise we get no JS into the PDF
\goto{toggle}[JS(toggleField)]
\blank
\setupfield[shortString][reset,horizontal][height=5mm, width=50mm, frame=off, bottomframe=on]
\starttext
\startJSpreamble {EXAMPLE}used now
function Dummy(){
return 0;
Current date: \field[myDateField]
 
\goto{END}[JS(Dummy)] % for MkIV bug
\stoptext
</texcode>
=Tricks and Traps=
'''Beware''', in ==MkIV the == * JS code is only copied to the PDF if there is 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 example at top. * JS code for default values doesn’t work.(reported 2015-04-01, still true 2015-10-0507). * There is no {{cmd|setupfields}} (plural)!
'''Beware''', there is no {{cmd|setupfields}} (plural)!==MkII==
This helps debugging (MkII only!):
<texcode>

Navigation menu