Difference between revisions of "Widgets"

From Wiki
Jump to navigation Jump to search
(Hints about deprecated logging commands in MkIV, changes of <cmd> to {{cmd|)
m (fix command reference \fillinline, remove link to old source file)
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] and [http://source.contextgarden.net/core-fld.tex core-fld.tex].
+
You find more about interactive elements in [http://www.pragma-ade.com/general/manuals/mwidget-s.pdf Widgets uncovered].
  
 
At the moment all of the following examples are from <tt>mwidget</tt> 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.
Line 48: Line 48:
 
* {{cmd|field}}
 
* {{cmd|field}}
 
* {{cmd|fillinfield}}
 
* {{cmd|fillinfield}}
* {{cmd|fillinlines}}
+
* {{cmd|fillinline}}
 
* {{cmd|fillintext}}
 
* {{cmd|fillintext}}
 
* {{cmd|fillinrules}}
 
* {{cmd|fillinrules}}

Revision as of 09:57, 31 March 2015

< Visuals | Interaction >

You find more about interactive elements in Widgets uncovered.

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

Beware, for fillinfields in MkIV you need \usemodule[fields]!

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

\definefield[name][type][setup name][content values][default content]

\field[name]

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 (MkII only!):

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