Debian Codegraph @

texmf-dist/doc/latex/grayhints/examples/gh-eforms.tex

raw
1 \documentclass{article}
2 \usepackage[designiv]{web}
3 \usepackage{grayhints}\previewOff
4
5 \addtoWebHeight{1in}
6 \def\cs#1{\texttt{\char`\\#1}}
7 \parindent0pt
8
9 %\EnterCommitFailEvent{\jsT\jsT
10 % event.target.strokeColor=color.red;\jsR\jsT\jsT
11 % event.value=(event.target.savevalue);}
12 %\CommitSuccessEvent{event.target.strokeColor=color.black;}
13
14 \begin{document}
15
16 \begin{center}
17 \large\bfseries Gray Hints
18 \end{center}
19 The `gray hint' technique requires modifications to the Format,
20 Keystroke, OnFocus, OnBlur, and Calculate events.\medskip
21
22 \textField[\textColor{\matchGray}
23 \TU{Enter your first name}
24 \AA{\AAFormat{\FmtToGray{First Name}}
25 \AAKeystroke{\KeyToGray}
26 \AAOnFocus{\JS{\FocusToBlack}}
27 \AAOnBlur{\JS{\BlurToBlack}}
28 \AACalculate{\CalcToGray}
29 }]{Name.First}{2in}{11bp}\cgBdry[1em]
30 \textField[\textColor{\matchGray}
31 \TU{Enter your last name}
32 \AA{\AAFormat{\FmtToGray{Last Name}}
33 \AAKeystroke{\KeyToGray}
34 \AAOnFocus{\JS{\FocusToBlack}}
35 \AAOnBlur{\JS{\BlurToBlack}}
36 \AACalculate{\CalcToGray}
37 }]{Name.Last}{2in}{11bp}\cgBdry[1em]\vcgBdry[3bp]
38 \textField[\textColor{\matchGray}
39 \TU{Enter a date of your choosing}
40 \AA{%
41 \AAOnFocus{\JS{\FocusToBlack}}
42 \AAKeystroke{\DateKeyEx("yyyy/mm/dd");\r
43 \KeyToGray}
44 \AAFormat{\DateFmtEx("yyyy/mm/dd");\r
45 \FmtToGray{yyyy/mm/dd}}
46 \AAOnBlur{\JS{\BlurToBlack}}
47 \AACalculate{\CalcToGray}
48 }]{Datefield}{1in}{11bp}\kern2bp\enspace$\Leftarrow$\enspace
49 \parbox{\linewidth-1in-2bp-\widthof{\enspace$\Leftarrow$\enspace}}
50 {\small Refer to \texttt{gh-fmts-eforms.tex} for additional discussion of
51 fields requiring special formatting.}\medskip
52
53 The next three fields perform calculations, the last one is the sum of the
54 first two. These are fields formatted as numbers. To prevent `Total' field
55 from displaying a zero (0) when the dependent fields are empty (and to
56 display its gray hint instead), a document JavaScript function was developed,
57 named \texttt{AllowCalc(cArray)}. This function returns \texttt{true} if any
58 of the fields listed in \texttt{cArray} has a value and returns
59 \texttt{false}, otherwise.\vcgBdry[6bp]
60
61 \textField[\TU{Enter an integer}
62 \textColor{\matchGray}\AA{%
63 \AAKeystroke{\NumKey(0,1,0,0,"",true);\r\KeyToGray}
64 \AAFormat{\NumFmt(0,1,0,0,"",true);\r\FmtToGray{First Integer}}
65 \AAOnFocus{\JS{\FocusToBlack}}
66 \AAOnBlur{\JS{\BlurToBlack}}
67 \AACalculate{\CalcToGray}
68 }]{Integer.First}{1in}{11bp}\vcgBdry[3bp]
69 \textField[\TU{Enter an integer}
70 \textColor{\matchGray}\AA{%
71 \AAKeystroke{\NumKey(0,1,0,0,"",true);\r\KeyToGray}
72 \AAFormat{\NumFmt(0,1,0,0,"",true);\r\FmtToGray{Second Integer}}
73 \AAOnFocus{\JS{\FocusToBlack}}
74 \AAOnBlur{\JS{\BlurToBlack}}
75 \AACalculate{\CalcToGray}
76 }]{Integer.Second}{1in}{11bp}\vcgBdry[3bp]
77 \textField[\TU{The total for first and second integers}
78 \textColor{\matchGray}\AA{%
79 \AAKeystroke{\NumKey(0,1,0,0,"",true);\r\KeyToGray}
80 \AAFormat{\NumFmt(0,1,0,0,"",true);\r\FmtToGray{Total}}
81 \AACalculate{var cArray=new Array("Integer");\r
82 if (AllowCalc(cArray))\SimpleCalc("SUM", cArray );\r\CalcToGray}
83 \AAOnFocus{\JS{\FocusToBlack}}
84 \AAOnBlur{\JS{\BlurToBlack}}
85 }]{TotalNumbers}{1in}{11bp}\medskip
86
87 The gray hint technique can apply to editable combo boxes as well.\vcgBdry[3bp]
88 \comboBox[\textColor{\matchGray}
89 \TU{Enter or choose your favorite food}\Ff{\FfEdit}
90 \AA{\AAFormat{\FmtToGray{Enter your favorite food}}
91 \AAKeystroke{\KeyToGray}
92 \AAOnFocus{\JS{\FocusToBlack}}
93 \AAOnBlur{\JS{\BlurToBlack}}
94 \AACalculate{\CalcToGray}
95 }]{combo}{1.65in}{11bp}{(Meat)(Potatoes)(Rice)(Onions)(Pickles)}\cgBdry[1em]
96 \pushButton[\CA{Reset}
97 \TU{Press to clear to clear all fields.}
98 \A{\JS{this.resetForm();}}]{reset}{}{11bp}\medskip
99
100 The color scheme of the gray hints is changed using
101 \cs{normalGrayColors}. The initial value of \cs{textColor}, which sets the
102 color of the text, must match, for appearance sake, the choice for the gray
103 color; for this reason, the \cs{matchGray} command was developed.\vcgBdry[6bp]
104
105 %\normalGrayColors{blue}{magenta}
106 \normalGrayColors{color.blue}{color.magenta}
107
108 \textField[\textColor{\matchGray}
109 \TU{Enter your favorite pet's name}
110 \AA{\AAFormat{\FmtToGray{Pet's name}}
111 \AAKeystroke{\KeyToGray}
112 \AAOnFocus{\JS{\FocusToBlack}}
113 \AAOnBlur{\JS{\BlurToBlack}}
114 \AACalculate{\CalcToGray}
115 }]{Pet}{1in}{11bp}
116
117 \end{document}