| 1 |
\documentclass{article} |
| 2 |
\usepackage[designiv]{web} |
| 3 |
\usepackage[usehyforms]{grayhints} |
| 4 |
|
| 5 |
\addtoWebHeight{1in} |
| 6 |
\def\cs#1{\texttt{\char`\\#1}} |
| 7 |
\parindent0pt |
| 8 |
|
| 9 |
%\EnterCommitFailEvent{\jsT\jsT |
| 10 |
% event.target.strokeColor=color.blue;\jsR\jsT\jsT |
| 11 |
% event.value=(event.target.savevalue);} |
| 12 |
%\CommitSuccessEvent{event.target.strokeColor=color.red;} |
| 13 |
|
| 14 |
|
| 15 |
\begin{document} |
| 16 |
\begin{Form} |
| 17 |
\begin{center}\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 |
\renewcommand\LayoutTextField[2]{\mbox{#2}} |
| 23 |
\renewcommand\LayoutChoiceField[2]{\mbox{#2}} |
| 24 |
|
| 25 |
\TextField[% |
| 26 |
name={Name.First}, |
| 27 |
height=11bp, |
| 28 |
width=2in, |
| 29 |
color={\matchGray}, |
| 30 |
keystroke=\KeyToGray, |
| 31 |
format={\FmtToGray{First Name}}, |
| 32 |
onfocus={\FocusToBlack}, |
| 33 |
onblur={\BlurToBlack}, |
| 34 |
calculate={\CalcToGray} |
| 35 |
]{First Name:}\quad |
| 36 |
\TextField[% |
| 37 |
name={Name.Laat}, |
| 38 |
height=11bp, |
| 39 |
width=2in, |
| 40 |
color={\matchGray}, |
| 41 |
keystroke=\KeyToGray, |
| 42 |
format={\FmtToGray{Last Name}}, |
| 43 |
onfocus={\FocusToBlack}, |
| 44 |
onblur={\BlurToBlack}, |
| 45 |
calculate={\CalcToGray} |
| 46 |
]{}\medskip |
| 47 |
|
| 48 |
\TextField[% |
| 49 |
name=Datefield, |
| 50 |
height=11bp, |
| 51 |
width=1in, |
| 52 |
color={\matchGray}, |
| 53 |
keystroke={\DateKeyEx("yyyy/mm/dd");\jsR\KeyToGray}, |
| 54 |
format={\DateFmtEx("yyyy/mm/dd");\jsR\FmtToGray{yyyy/mm/dd}}, |
| 55 |
onfocus={\FocusToBlack}, |
| 56 |
onblur={\BlurToBlack}, |
| 57 |
calculate={\CalcToGray} |
| 58 |
]{}\enspace$\Leftarrow$\enspace |
| 59 |
\parbox{\linewidth-1in-\widthof{\enspace$\Leftarrow$\enspace}} |
| 60 |
{\small Refer to \texttt{gh-fmts-hyperref.tex} for additional discussion of |
| 61 |
fields requiring special formatting.}\medskip |
| 62 |
|
| 63 |
The next three fields perform calculations, the last one is the sum of the |
| 64 |
first two. These are fields formatted as numbers. To prevent `Total' field |
| 65 |
from displaying a zero (0) when the dependent fields are empty (and to |
| 66 |
display its gray hint instead), a document JavaScript function was developed, |
| 67 |
named \texttt{AllowCalc(cArray)}. This function returns \texttt{true} if any |
| 68 |
of the fields listed in \texttt{cArray} has a value and returns |
| 69 |
\texttt{false}, otherwise.\smallskip |
| 70 |
|
| 71 |
\TextField[% |
| 72 |
name=Integer.First, |
| 73 |
height=11bp, |
| 74 |
width=1in, |
| 75 |
color={\matchGray}, |
| 76 |
keystroke={\NumKey(0,1,0,0,"",true);\KeyToGray}, |
| 77 |
format={\NumFmt(0,1,0,0,"",true); \FmtToGray{First Integer}}, |
| 78 |
onfocus={\FocusToBlack}, |
| 79 |
onblur={\BlurToBlack}, |
| 80 |
calculate={\CalcToGray} |
| 81 |
]{}\smallskip |
| 82 |
|
| 83 |
\TextField[% |
| 84 |
name=Integer.Second, |
| 85 |
height=11bp, |
| 86 |
width=1in, |
| 87 |
color={\matchGray}, |
| 88 |
keystroke={\NumKey(0,1,0,0,"",true); \KeyToGray}, |
| 89 |
format={\NumFmt(0,1,0,0,"",true); \FmtToGray{Second Integer}}, |
| 90 |
onfocus={\FocusToBlack}, |
| 91 |
onblur={\BlurToBlack}, |
| 92 |
calculate={\CalcToGray} |
| 93 |
]{}\smallskip |
| 94 |
|
| 95 |
% The use of \jsR (\jsT) is for editing purposes, should you have Acrobat or PDF-XChange Pro; otherwise, they are optional |
| 96 |
\TextField[% |
| 97 |
name=TotalNumber, |
| 98 |
height=11bp, |
| 99 |
width=1in, |
| 100 |
color={\matchGray}, |
| 101 |
keystroke={\NumKey(0,1,0,0,"",true);\jsR\KeyToGray}, |
| 102 |
format={\NumFmt(0,1,0,0,"",true);\jsR\FmtToGray{Total}}, |
| 103 |
calculate={var cArray=new Array("Integer");\jsR |
| 104 |
if (AllowCalc(cArray))\SimpleCalc("SUM", cArray );\jsR\CalcToGray}, |
| 105 |
onfocus={\FocusToBlack}, |
| 106 |
onblur={\BlurToBlack} |
| 107 |
]{}\medskip |
| 108 |
|
| 109 |
The gray hint technique can apply to editable combo boxes as well.\smallskip |
| 110 |
|
| 111 |
\ChoiceMenu[% |
| 112 |
name=combo, |
| 113 |
combo, |
| 114 |
width=1.65in, |
| 115 |
height=11bp, |
| 116 |
edit, |
| 117 |
color={\matchGray}, |
| 118 |
keystroke={\KeyToGray}, |
| 119 |
format={\FmtToGray{Enter your favorite food}}, |
| 120 |
onfocus={\FocusToBlack}, |
| 121 |
onblur={\BlurToBlack}, |
| 122 |
calculate={\CalcToGray} |
| 123 |
]{}{Meat,Potatoes,Rice,Onions,Pickles}\medskip |
| 124 |
|
| 125 |
The color scheme of the gray hints can be changed using |
| 126 |
\cs{normalGrayColors}. The initial value of \cs{textColor}, which sets the |
| 127 |
color of the text, must match, for appearance sake, the choice for the gray |
| 128 |
color; for this reason, the \cs{matchGray} command was developed.\smallskip |
| 129 |
|
| 130 |
|
| 131 |
\normalGrayColors{color.blue}{color.magenta} |
| 132 |
|
| 133 |
\TextField[% |
| 134 |
name=Pet, |
| 135 |
width=1in, |
| 136 |
height=11bp, |
| 137 |
color={\matchGray}, |
| 138 |
keystroke={\KeyToGray}, |
| 139 |
format={\FmtToGray{Pet's name}}, |
| 140 |
onfocus={\FocusToBlack}, |
| 141 |
onblur={\BlurToBlack}, |
| 142 |
calculate={\CalcToGray} |
| 143 |
]{Pet}\medskip |
| 144 |
|
| 145 |
\PushButton[% |
| 146 |
height=11bp, |
| 147 |
name=reset, |
| 148 |
onclick={this.resetForm();}]{Reset} |
| 149 |
|
| 150 |
\end{Form} |
| 151 |
\end{document} |