Difference between revisions of "Widgets"

From Wiki
Jump to navigation Jump to search
(new (incomplete, but must save...))
 
(more about \definefield etc.)
Line 1: Line 1:
 
< [[Visuals]] | [[Interaction]] >
 
< [[Visuals]] | [[Interaction]] >
  
You find more about interactive elements in [http://www.pragma-ade.com/general/manuals/mwidget-s.pdf Widgets uncovered].
+
You find more about interactive elements in [http://www.pragma-ade.com/general/manuals/mwidget-s.pdf Widgets uncovered] and [http://source.contextgarden.net/core-fld.tex core-fld.tex].
  
At the moment all of the following examples are from this manual. We will cook up our own later.
+
At the moment all of the following examples are from <tt>mwidget</tt> manual. We will cook up our own later.
  
 
For PDF is only an interface, you need JavaScript to handle interaction (field input etc.).
 
For PDF is only an interface, you need JavaScript to handle interaction (field input etc.).
Line 41: Line 41:
 
==Text Entries==
 
==Text Entries==
  
 +
see
 +
* <cmd>setupfield</cmd>, <cmd>setupfields</cmd>
 +
* <cmd>definefield</cmd>
 +
* <cmd>field</cmd>
 
* <cmd>fillinfield</cmd>
 
* <cmd>fillinfield</cmd>
 
* <cmd>fillinlines</cmd>
 
* <cmd>fillinlines</cmd>
Line 52: Line 56:
 
\field [Email] [your email]
 
\field [Email] [your email]
 
</texcode>
 
</texcode>
 +
 +
<cmd>definefield</cmd><tt>[name][type][setup name][?don't know?][default content]</tt>
 +
 +
<cmd>field</cmd><tt>[name][?don't know?]</tt>
  
 
==Radiobuttons==
 
==Radiobuttons==

Revision as of 12:48, 7 January 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.).

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

Fields

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