Open main menu

< Visuals | Interaction >

You find more about interactive elements in Widgets uncovered and core-fld.tex.

At the moment all of the following examples are from mwidget manual. We will cook up our own later.

For PDF is only an interface, you need JavaScript to handle interaction (field input etc.).

JavaScript

\startJSpreamble {name}
MyCounter = 0 ;
\stopJSpreamble

\startJScode {increment}
MyCounter = MyCounter + 1 ; // or: ++MyCounter ;
\stopJScode

\goto {advance by one} [JS(increment)]

You can pass values to a JS function:

\startJScode {increment}
MyCounter = MyCounter + JS_V_1 ;
\stopJScode

\goto {advance by five} [JS(increment{V{5}})]
  • V{} is verbose, defaults to string
  • S{} = as string
  • R{} = as reference
  • JS_V_n, JS_S_n, JS_R_n are the names of the variables
  • JS_N keeps the number of arguments

Fields

 
Someone thinks this entry needs some more explanation. (See: Needs Explanation?, To-Do List.)


Text Entries

see

\fillinfield[name]{text that defines field length}
% or
\definefield [Email] [line] [ShortLine] [] [sample@contextgarden.net]
\field [Email] [your email]

\definefield[name][type][setup name][?don't know?][default content]

\field[name][?don't know?]

Radiobuttons

Sample from the manual:

\setupfield [LogoSetup]
        [width=4cm,
        height=4cm,
        frame=off,
        background=screen]

\definefield[Logos] [radio] [LogoSetup]
[ConTeXt,PPCHTEX,TeXUtil] [PPCHTEX]

\definesubfield [ConTeXt] [] [ConTeXtLogo]
\definesubfield [PPCHTEX] [] [PPCHTEXLogo]
\definesubfield [TeXUtil] [] [TeXUtilLogo]

\definesymbol [ConTeXtLogo] [{\externalfigure[mpcont.502]}]
\definesymbol [PPCHTEXLogo] [{\externalfigure[mpcont.503]}]
\definesymbol [TeXUtilLogo] [{\externalfigure[mpcont.504]}]

\hbox to \hsize{\hss\field[ConTeXt]\hss\field[PPCHTEX]\hss\field[TeXUtil]\hss}

Checkboxes

\setupfield[setup 3]
        [width=2cm, height=2cm,
        rulethickness=3pt, corner=round, framecolor=red]

\definesymbol [yes] [{\externalfigure[mpcont.502]}]
\definesymbol [no] []
\definefield [checkme][check] [setup 3] [yes,no] [no]
\field[checkme]

Tricks

This helps debugging:

\tracefieldstrue
\showfields  % typeset a table of field relations
\logfields     % logs field descriptions to a file fields.log