[Tex/LaTex] question on radiobuttons ( \ChoiceMenu[radio,…] ) of a fillable form made with package hyperref

formshyperrefpdf

I often use radiobuttons ( \ChoiceMenu[radio,…] ). But there is one aspect I am not happy about: If you select/check a certain button of your group of radiobuttons, then without javascript there is no way to have all radiobuttons of the group again deselected/unchecked.

A little example:

\documentclass{article}
\usepackage[bookmarks=false]{hyperref}
\begin{document}
\begin{Form}
{Do you want to: }%
\ChoiceMenu[radio,radiosymbol=\ding{52},name=myGroupOfRadiobuttons]{}{Do it all again=Again}
\ChoiceMenu[radio,radiosymbol=\ding{52},name=myGroupOfRadiobuttons]{}{Pretend it never happened=Pretend}
\ChoiceMenu[radio,radiosymbol=\ding{52},name=myGroupOfRadiobuttons]{}{Write a book about it=Write}
\end{Form}
\end{document}

I would like to get such a behavior of a group of radiobuttons as in section "Filling Status" in the upper part of this governmental fillable pdf form. If a selected/checked radiobutton once more is checked/selected, then the selection completely vanishes.

Is ist possible to produce such a group of radiobuttons with LaTex and hyperref without javascript? The above linked pdf is made with the software "Adobe LifeCycle Designer".


Edit: (Peter Grill)

Initially the above produces:

enter image description here

Upon clicking on the first check box, we get:

enter image description here

The goal is to be able to check the first box in this state and revert back to the initial state (first image).

Best Answer

There's a flag called NoToggleToOff which should control this behavior according to the PDF specification, p. 439:

(Radio buttons only) If set, exactly one radio button shall be selected at all times; selecting the currently selected button has no effect. If clear, clicking the selected button deselects it, leaving no button selected.

However, this does not work as expected: even if the flag is not set, I wasn't able to deselect a once selected radio button. I tried with different viewers (Adobe Reader X, PDF-XChange Viewer, Foxit Reader [Windows]) and with PDF documents produced by different programs (LaTeX using hyperref, OpenOffice, iText), with no success. Apparently, this feature of the specification isn't implemented in any of the current PDF viewers!

So how were the radio buttons in the linked form created?

The answer is quite surprising: The "radio buttons" in this PDF don't have the Radio flag set, which technically turns them into simple check boxes. However, as you can see, they still behave like radio buttons, so you can only select one option at a time. You can exploit this oddity by removing this flag in the form fields created by hyperref:

\documentclass{article}
\usepackage[bookmarks=false]{hyperref}

% Make radio buttons completely deselectable by removing the "Radio" flag
% (http://tex.stackexchange.com/a/74543/3323)
\usepackage{etoolbox}
\makeatletter
\patchcmd{\HyField@FlagsRadioButton}{\HyField@SetFlag{Ff}{Radio}}{}{}{}
\makeatother
\def\DefaultOptionsofRadio{print}

\begin{document}
\begin{Form}
{Do you want to: }%
\ChoiceMenu[radio,radiosymbol=\ding{52},name=myGroupOfRadiobuttons]{}{Do it all again=Again}
\ChoiceMenu[radio,radiosymbol=\ding{52},name=myGroupOfRadiobuttons]{}{Pretend it never happened=Pretend}
\ChoiceMenu[radio,radiosymbol=\ding{52},name=myGroupOfRadiobuttons]{}{Write a book about it=Write}
\end{Form}
\end{document}

Like this, you get completely deselectable radio buttons like the ones in the form you provided.