interaction-buttons.tex /size: 2923 b    last modification: 2021-10-28 13:50
1\environment interaction-style
2
3\startcomponent interaction-buttons
4
5\startchapter[title={Buttons}]
6
7There is not much to tell about buttons. They are clickable areas on the screen
8that when clicked on bring you some location or invoke some action in the viewer,
9for instance triggered by a \JAVASCRIPT. As usual with many commands, you can
10define categories of buttons and set them up globally or per category.
11
12\showsetup{definebutton}
13
14\showsetup{setupbutton}
15
16The default button command is:
17
18\showsetup{button}
19
20Buttons are an example of a construct that builds upon \type {\framed} so the
21keys that apply there also apply to buttons. You can enable or disable buttons
22with the \type {state} parameter. As usual there are a \type {style} and \type
23{color} parameters and an additional \type {contrastcolor} option for tuning the
24color of a button which action let you stay on the same page. Actually, when you
25do stay on the same page, the \type {samepage} parameter let you control if the
26button should be empty, hidden or whatever.
27
28\starttabulate[|B|c|c|c|]
29\NC                 \BC frame \BC text \BC shown \NC \NR
30\NC \type {yes}     \NC +     \NC +    \NC +     \NC \NR % 0
31\NC \type {empty}   \NC +     \NC -    \NC +     \NC \NR % 1
32\NC \type {no}      \NC -     \NC -    \NC +     \NC \NR % 2
33\NC \type {none}    \NC -     \NC -    \NC -     \NC \NR % 3
34\NC \type {normal}  \NC +     \NC +    \NC +     \NC \NR % 1
35\NC \type {default} \NC +     \NC +    \NC +     \NC \NR % 1
36\stoptabulate
37
38Here is an example of a button:
39
40\startbuffer
41\button
42  [background=color,backgroundcolor=darkred,
43   style=bold,color=white,
44   framecolor=blue,rulethickness=2pt,
45   width=3cm,height=1.5cm]
46  {go to the next page}
47  [nexpage]
48\stopbuffer
49
50\typebuffer
51
52This colorful button shows up as:
53
54\startlinecorrection
55\getbuffer
56\stoplinecorrection
57
58When you use interaction in presentations you might want to make the page
59and|/|or text area active. Here is an example.
60
61\starttyping
62\defineoverlay
63  [PrevPage]
64  [\overlaybutton{PrevPage}]
65
66\setupbackgrounds
67  [page]
68  [background=PrevPage]
69
70\setuptexttexts
71  [\overlaybutton{NextPage}]
72\stoptyping
73
74We provide two variants: the normal one with square brackets, but also a more
75direct one that accepts curly braces, which is handy when you pass an overlay
76button as argument.
77
78\showsetup {overlaybutton}
79\showsetup {overlaybutton:direct}
80
81The difference in usage is shown here:
82
83\starttyping
84\setuptexttexts [\overlaybutton{NextPage}]
85\setuptexttexts[{\overlaybutton[NextPage]}]
86\stoptyping
87
88An overlay button adapts its size to the current overlay so you don't need to
89worry about passing dimensions.
90
91It is possible to define more complex buttons, like roll|-|over buttons or
92buttons that change appearance when you click on them. These are more resource
93hungry and also depend on the viewer. These will discussed in the chapter about
94widgets.
95
96\stopchapter
97
98\stopcomponent
99