ma-cb-en-interactivity.tex /size: 8918 b    last modification: 2020-07-01 14:35
1\startcomponent ma-cb-en-interactivity
2
3\enablemode[**en-us]
4
5\project ma-cb
6
7\startchapter[title=Interactive mode in electronic documents,reference=interactivity]
8
9\startsection[title=Introduction]
10
11\index[reader]{\READER}
12
13Documents that are electronically available for consulting and displaying on a
14computer screen are called interactive documents.
15
16Interaction means that you can click on active areas and jump to the indicated
17locations. For example if you consult a register you can click on a (active) page
18number and you will jump to the corresponding page.
19
20Interaction relates to:
21
22\startitemize[packed]
23\item active chapter numbers in the table of content
24\item active page numbers in registers
25\item active page numbers, chapter numbers and figure numbers in internal
26      references to pages, chapters, figures etc. in the running text
27\item active titles, page numbers, and chapter numbers in external references to
28      other interactive documents
29\item active menus as navigation tools
30\item references to webpages and programs
31\stopitemize
32
33Interactivity depends on the program you use to view the interactive document. We
34assume here that you will use \READER\ for viewing.
35
36\CONTEXT\ is a very powerful system for producing electronic or interactive \PDF\
37documents. However, only a few standard features are described in this chapter. As
38the authors of this manual are planning to make all \CONTEXT\ related manuals
39electronically (sources included) available, reverse engineering is one of the
40options to become more acquainted with the possibilities of \CONTEXT.
41
42Good examples of interactive documents are \CONTEXT\ presentations (see \in{chapter}[presentations]).
43For more complex interactive \PDF\ documents with forms you should read the
44\goto {Widgets} [ url (manual:widget) ]
45manual.
46
47\stopsection
48
49\startsection[title=Interactive mode]
50
51\index{interactive mode}
52
53\Command{\tex{setupinteraction}}
54
55The interactive mode is activated by:
56
57\shortsetup{setupinteraction}
58
59For example:
60
61\startbuffer
62\setupinteraction
63  [state=start,
64   color=green,
65   style=bold]
66\stopbuffer
67
68\typebuffer
69
70The hyper links are now generated automatically and the active words are
71displayed in bold green.
72
73The interactive document is considerably bigger (in MB's) than its paper cousin
74because hyperlinks consume space. You will also notice that processing time
75becomes longer. Therefore it is advisable to de-activate the interactive mode as
76long as your document is under construction.
77
78\stopsection
79
80\startsection[title=Interaction within a document]
81
82\index{interaction+internal}
83
84\Command{\tex{in}}
85\Command{\tex{at}}
86\Command{\tex{goto}}
87
88Earlier you have seen how to make a reference with \type{\in} and \type{\at}. You
89may have wondered why you had to type \type{\in{chapter}[chap:introduction]}. In
90the first place {\em chapter} and its corresponding chapter number will not be
91separated at line breaking. In the second place the word {\em chapter} and its
92number are typeset differently in the interactive mode. This gives the user a
93larger clickable area.
94
95\stopsection
96
97\startsection[title=Interaction between documents]
98
99\index{interaction+external}
100
101\Command{\tex{from}}
102\Command{\tex{useexternaldocument}}
103
104It is possible to link one document to another. First you have to state that you
105want to refer to another document. This is done by:
106
107\shortsetup{useexternaldocument}
108
109The first bracket pair must contain a logical name of the document, the second
110pair the file name of the other document and the third pair is used for the title
111of the document.
112
113For refering to these other documents you can use:
114
115\shortsetup{from}
116
117The curly braces contain text and the brackets contain the reference.
118
119Look at the example below.
120
121\startbuffer
122\useexternaldocument
123   [hia][hasseltbook][Festivities in Hasselt]
124
125Most tourist attractions are described in \from[hia].\crlf
126A description of the \about[hia::euifeest] is found in \from[hia].\crlf
127The eui||feest is described on \at{page}[hia::euifeest] in \from[hia].\crlf
128See for more information \in{chapter}[hia::euifeest] in \from[hia].
129\stopbuffer
130
131\typebuffer
132
133The \type{\useexternaldocument} is usually typed in the set up area of your input
134file.
135
136After processing your input file and the file \type{hasseltbook.tex},
137you will have two \PDF\ documents. The references come out like this:
138
139\start
140\setupinteraction[state=start]
141\getbuffer
142\stop
143
144For more information on cross referencing look at
145\goto {\CONTEXT\ Magazine 1103} [ url (thisway:crossrefs)].
146
147\stopsection
148
149\startsection[title=Interaction with the world wide web]
150
151In interactive mode there is one other command that has little meaning in the
152paper version.
153
154\shortsetup{goto}
155
156The curly braces contain text, the brackets contain a reference (logical name or a
157location).
158
159\startbuffer
160In \goto {Hasselt} [ url(http://www.stadindex.nl/plattegrond/hasselt) ]
161all streets are build in a circular way.
162\stopbuffer
163
164\typebuffer
165
166In the interactive document \goto{Hasselt}[ url(http://www.stadindex.nl/plattegrond/hasselt) ]
167will be green and active. When you click the text you will jump to a map of Hasselt.
168
169For a consistent definition of the urls there is the command:
170
171\shortsetup{useURL}
172
173The adress is defined with:
174
175\startbuffer
176\useURL
177  [loc:cityplan]                                % id
178  [http://www.stadindex.nl/plattegrond/hasselt] % adress
179  []                                            % document
180  []                                            % text
181\stopbuffer
182
183\typebuffer
184
185The webadress is recalled by its logical name:
186\type{\goto {Hasselt} [ url(loc:cityplan) ]}.
187
188It is of good practice to define and maintain the urls in a separate
189file.
190
191\stopsection
192
193\startsection[title=Buttons]
194
195The command to define a button is:
196
197\shortsetup{button}
198
199The first bracket pair contains the setup keys, the curly brackets contain the
200button text and the last bracket pair the destination.
201
202\startbuffer
203\useexternalsoundtrack
204  [stranger][wayfaring_stranger.mp3]
205
206\button{Website Hasselt} [ url(http://www.hasselt.nl) ]
207\button{MSWord Document} [ program(hasselt.doc) ]
208\button{Sound Clip}      [ StartSound{stranger} ]
209\stopbuffer
210
211\typebuffer
212
213The first example results in a jump to a webpage, the second opens the file
214\type{hasselt.doc} in \MSWORD\ and the third plays a tune. Note the use of the
215\type{\useexternalsoundtrack} command.
216
217\stopsection
218
219\startsection[title=Menus]
220
221You can define a menu with:
222
223\shortsetup{startinteractionmenu}
224
225And set it up with:
226
227\shortsetup{setupinteractionmenu}
228
229The first bracket pair is used for its name and the second pair for setting up
230the menu.
231
232A menu can be used in an interactive document. Below you can find a simple
233example that you can copy to do some experimenting:
234
235\startbuffer
236\setuppapersize
237  [S6][S6]
238
239\setuplayout
240  [header=0cm,          topspace=.5cm, backspace=2cm,
241   margindistance=.5cm, margin=1cm,    rightmargin=0cm,
242   edgedistance=.5cm,   rightedge=2cm, width=fit,
243   height=13.8cm,       footer=1cm,    bottom=1cm]
244
245\setupinteraction
246  [state=start,         menu=on]
247
248\setupinteractionmenu
249  [bottom]
250  [background=color,    backgroundcolor=gray, frame=off]
251
252\startinteractionmenu[bottom]
253\hfill
254\startbut [content]       contents      \stopbut \quad
255\startbut [index]         index         \stopbut \quad
256\startbut [PreviousJump]  last location \stopbut \quad
257\startbut [NextPage]      next page     \stopbut \quad
258\startbut [CloseDocument] exit          \stopbut \quad
259\stopinteractionmenu
260
261\starttext
262
263\startstandardmakeup
264  \midaligned{\tfd Festivities in Hasselt}
265\stopstandardmakeup
266
267\completecontent
268
269\startchapter[title=Introduction]
270  An introduction.
271\stopchapter
272
273\startchapter[title=Kingsday]
274  Something about Kingsday in Hasselt.\index{Kingsday}
275\stopchapter
276
277\startchapter[title=Hassailt]
278  Something about Hassailt.\index{Hassailt}
279\stopchapter
280
281\startchapter[title=Euifeest,reference=euifeest]
282  Something about the Euifeest.\index{Euifeest}
283\stopchapter
284
285\completeindex
286
287\stoptext
288\stopbuffer
289
290\typebuffer
291
292The definition of the \type{\startinteractionmenu} will produce a menu at the
293bottom of every screen. The menu buttons contain the text {\em contents}, {\em
294index}, {\em last location}, {\em next page} and {\em exit} with respectively the
295following functions: jump to the table of contents, jump to the index, goto the
296last location in the document, goto next page and close the document. The labels
297to obvious destinations like \type{content} and \type{index} are predefined.
298Other predefined destinations are \type{FirstPage}, \type{LastPage},
299\type{NextPage} and \type{PreviousPage}.
300
301An action like \type{CloseDocument} is necessary to make an electronic document
302self containing. Other predefined actions you can use are \type{PrintDocument},
303\type{SearchDocument} and \type{PreviousJump}. The meaning of these actions is
304obvious.
305
306\stopsection
307
308\stopchapter
309
310\stopcomponent
311