On 2015-04-02 03:42, Henning Hraban Ramm wrote:
Hello,
while trying to create some interactive forms using latest beta (MkIV), I found
that JavaScripts are only then copied into the PDF, if there’s a \goto
referencing a JS function.
According to the old widgets manual I thought I could set default values of
fields calling JS functions or variables as [JS(MyFunc)], but that doesn’t work.
\starttext
\setupinteraction [state=start]
\startJSpreamble{formtest}
% this JS code is only copied to the PDF if the \goto below is uncommented!
var d = new Date();
var df = this.getField("Datum");
var CurDate = util.printd("dd.mm.yyyy", d);
df.value = CurDate;
function toggleField(){
var f = this.getField("Datum");
f.display = ! f.display;
}
\stopJSpreamble
%\goto{toggle}[JS(toggleField)]
\blank
\setupfield[MMshortString][reset,horizontal][height=5mm, width=50mm, frame=off,
bottomframe=on]
\definefield[Datum][line][MMshortString][][JS(CurDate)] % JS(CurDate) ends up
verbatim in the field
Date: \field[Datum]
\stoptext
Greetlings, Hraban
Greetlings Hraban,
This appears to be a pdf reader problem. On Win 8.1, Windows Reader and
Chrome both show an editable field; Firefox and Sumatra show a
non-editable field.
--
Rik
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________