Difference between revisions of "Widgets"

From ConTeXt wiki
Jump to navigationJump to search
(more about \definefield etc.)
m (Added a TODO for explanation.)
Line 38: Line 38:
==Text Entries==
==Text Entries==

Revision as of 06:41, 5 September 2005

< 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.).


\startJSpreamble {name}
MyCounter = 0 ;

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

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

You can pass values to a JS function:

\startJScode {increment}
MyCounter = MyCounter + JS_V_1 ;

\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_nm JS_R_n are the names of the variables
  • JS_N keeps the number of arguments


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

Text Entries


\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?]


Sample from the manual:

\setupfield [LogoSetup]

\definefield[Logos] [radio] [LogoSetup]

\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}


\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]


This helps debugging:

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