summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/grayhints/examples/gh-hyperref.tex
blob: dcb240477abf71975cc893b019225d1dbf8d6e03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
\documentclass{article}
\usepackage[designiv]{web}
\usepackage[usehyforms]{grayhints}

\addtoWebHeight{1in}
\def\cs#1{\texttt{\char`\\#1}}
\parindent0pt


\begin{document}
\begin{Form}
\begin{center}\large\bfseries Gray Hints
\end{center}
The `gray hint' technique requires modifications to the Format,
Keystroke, OnFocus, and OnBlur events.\medskip

\renewcommand\LayoutTextField[2]{#2}
\renewcommand\LayoutChoiceField[2]{#2}

\TextField[%
    name={Name.First},
    height=11bp,
    width=2in,
    color={\matchGray},
    keystroke=\KeyToGray,
    format={\FmtToGray{First Name}},
    onfocus={\FocusToBlack},
    onblur={\BlurToBlack}]{First Name:}\quad
\TextField[%
    name={Name.Laat},
    height=11bp,
    width=2in,
    color={\matchGray},
    keystroke=\KeyToGray,
    format={\FmtToGray{Last Name}},
    onfocus={\FocusToBlack},
    onblur={\BlurToBlack}]{}\medskip

\TextField[%
    name=Datefield,
    height=11bp,
    width=1in,
    color={\matchGray},
    keystroke={AFDate_KeystrokeEx("yyyy/mm/dd");\KeyToGray},
    format={AFDate_FormatEx("yyyy/mm/dd");\FmtToGray{yyyy/mm/dd}},
    onfocus={\FocusToBlack},
    onblur={\BlurToBlack}]{}\medskip

The next three fields perform calculations, the last one is the sum of the
first two. These are fields formatted as numbers. To prevent `Total' field
from displaying a zero (0) when the dependent fields are empty (and to
display its gray hint instead), a document JavaScript function was developed,
named \texttt{AllowCalc(cArray)}. This function returns \texttt{true} if any
of the fields listed in \texttt{cArray} has a value and returns
\texttt{false}, otherwise.\smallskip

\TextField[%
    name=Integer.First,
    height=11bp,
    width=1in,
    color={\matchGray},
    keystroke={AFNumber_Keystroke(0,1,0,0,"",true);\KeyToGray},
    format={AFNumber_Format(0,1,0,0,"",true); \FmtToGray{First Integer}},
    onfocus=\FocusToBlack,
    onblur=\BlurToBlack
]{}\smallskip

\TextField[%
    name=Integer.Second,
    height=11bp,
    width=1in,
    color=\matchGray,
    keystroke={AFNumber_Keystroke(0,1,0,0,"",true); \KeyToGray},
    format={AFNumber_Format(0,1,0,0,"",true); \FmtToGray{Second Integer}},
    onfocus=\FocusToBlack,
    onblur=\BlurToBlack
]{}\smallskip

\TextField[%
    name=TotalNumber,
    height=11bp,
    width=1in,
    color=\matchGray,
    keystroke={AFNumber_Keystroke(0,1,0,0,"",true);\KeyToGray},
    format={AFNumber_Format(0,1,0,0,"",true); \FmtToGray{Total}},
    calculate={var cArray=new Array("Integer");
        if (AllowCalc(cArray))AFSimple_Calculate("SUM", cArray ); \CalcToGray},
    onfocus=\FocusToBlack,
    onblur=\BlurToBlack
]{}\medskip

The gray hint technique can apply to editable combo boxes as well.\smallskip

\ChoiceMenu[%
    name=combo,
    combo,
    width=1.65in,
    height=11bp,
    color={\matchGray},
    edit,
    keystroke=\KeyToGray,
    format={\FmtToGray{Enter your favorite food}},
    onfocus=\FocusToBlack,
    onblur=\BlurToBlack
]{}{Meat,Potatoes,Rice,Onions,Pickles}\medskip

The color scheme of the gray hints can be changed using
\cs{normalGrayColors}. The initial value of \cs{textColor}, which sets the
color of the text, must match, for appearance sake, the choice for the gray
color; for this reason, the \cs{matchGray} command was developed.\smallskip

\normalGrayColors{color.blue}{color.magenta}

\TextField[%
    name=Pet,
    width=1in,
    height=11bp,
    color=\matchGray,
    keystroke=\KeyToGray,
    format=\FmtToGray{Pet's name},
    onfocus=\FocusToBlack,
    onblur=\BlurToBlack
]{Pet}\medskip

\PushButton[%
    height=11bp,
    name=reset,
    onclick={this.resetForm();}]{Reset}\medskip

\end{Form}
\end{document}