Changes

Jump to navigation Jump to search
825 bytes added ,  08:14, 5 October 2015
still working on the example / explaining radio buttons
</texcode>
'''Beware''', in MkIV (as of 2015-04-01) the JS code is only copied to the PDF if there is a \goto referencing one of the defined functions!
You can pass values to a JS function:
===Setting the current date===
This is Similar, but more usable than the example above:
<texcode>
\starttext
 
\startJSpreamble {EXAMPLE}
function Dummy(){
return 0;
}
 
function setCurrentDate(fieldname) {
var f = this.getField(fieldname);
\setupfield[dateString][reset,horizontal][width=5em,option=printable]
\definefield[myDateField][line][dateString][][JavaScript should replace this text with the current date] Current date: \field[myDateField]
\goto{END}[JS(Dummy)] % for MkIV bug
\stoptext
</texcode>
==Radiobuttons==
Sample Example from the manual: (Note that background=screen is depricated in MKIV and should be replaced by something like background=color,backgroundcolor=lightgray.)
<texcode>
height=4cm,
frame=off,
background=screencolor, backgroundcolor=lightgray]
\definefield[Logos] [radio] [LogoSetup][ConTeXt,PPCHTEX,TeXUtil] [PPCHTEX]
\hbox to \hsize{\hss\field[ConTeXt]\hss\field[PPCHTEX]\hss\field[TeXUtil]\hss}
</texcode>
 
As usual, first you need to define a class of fields ({{cmd|setupfield}}). Then you define the (invisible) group of radio buttons ({{cmd|definefield}} with "radio"). At last you define the single radio buttons with {{cmd|setupsubfield}}.
 
Arguments of {{cmd|definefield}}:
# field name
# field type "radio"
# setup class, as defined by {{cmd|setupfield}}
# list of field names that should be part of the group
# name of default (activated) button
 
Arguments of {{cmd|definesubfield}}:
# field name
# setup class (default is inherited, but you can use a different one)
# content symbol, defined by {{cmd|definesymbol}}
==Checkboxes==
=Tricks and Traps=
'''Beware''', in MkIV the JS code is only copied to the PDF if there is a \goto referencing one of the defined functions!(reported 2015-04-01, still true 2015-10-05) '''Beware''', there is no {{cmd|setupfields}} (plural), at least in MkIV as of 2015-10-05.!
This helps debugging (MkII only!):

Navigation menu