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|)
Line 44: Line 44:
  
 
see
 
see
* <cmd>setupfield</cmd>, <cmd>setupfields</cmd>
+
* {{cmd|setupfield}}, {{cmd|setupfields}}
* <cmd>definefield</cmd>
+
* {{cmd|definefield}}
* <cmd>field</cmd>
+
* {{cmd|field}}
* <cmd>fillinfield</cmd>
+
* {{cmd|fillinfield}}
* <cmd>fillinlines</cmd>
+
* {{cmd|fillinlines}}
* <cmd>fillintext</cmd>
+
* {{cmd|fillintext}}
* <cmd>fillinrules</cmd>
+
* {{cmd|fillinrules}}
 +
 
 +
Beware, for fillinfields in MkIV you need {{code|\usemodule[fields]}}!
  
 
<texcode>
 
<texcode>
Line 59: Line 61:
 
</texcode>
 
</texcode>
  
<cmd>definefield</cmd><tt>[name][type][setup name][?don't know?][default content]</tt>
+
{{cmd|definefield|[name][type][setup name][content values][default content]}}
  
<cmd>field</cmd><tt>[name][?don't know?]</tt>
+
{{cmd|field|[name]}}
  
 
==Radiobuttons==
 
==Radiobuttons==
Line 103: Line 105:
 
=Tricks=
 
=Tricks=
  
This helps debugging:
+
This helps debugging (MkII only!):
  
 
<texcode>
 
<texcode>

Revision as of 09:55, 31 March 2015

< 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

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