Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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).

share|improve this question
    
Welcome to TeX.SE. It is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. This will also serve as a test case and ensure that the solution actually works for you. –  Peter Grill Jun 4 '12 at 0:26
    
Oh yes, you are right. I changed my post. It now contains an MWE. –  Zdenko Jun 4 '12 at 1:15
    
Thanks. Can you also elaborate on what you mean by "If a selected/checked radiobutton once more is checked/selected, then the selection completely vanishes". I downloaded the form and using Acrobat 10.1.3 on a Mac I did not see the radio buttons vanishing. –  Peter Grill Jun 4 '12 at 1:28
    
I do not want the radiobutton to vanish. I want its selection to vanish. If a radiobutton is pressed, I would want to undo it without having to press an other buttton of the radio button group. –  Zdenko Jun 4 '12 at 1:51
    
If you do a doubleclick at the radio button field "single" in the section "Filling Status" of the linked pdf, zero radio buttons will be pressed. Thats the aimed behavior I would like to reach using LaTex, hyperref and Form. –  Zdenko Jun 4 '12 at 2:06
show 1 more comment

2 Answers

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.

share|improve this answer
add comment
\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,%
Pretend it never happened=Pretend,Write a book about it=Write}
\end{Form}
\end{document}
share|improve this answer
    
Welcome to TeX.sx! A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). Could you also add a few words on how your answer works? –  doncherry Jun 8 '12 at 17:01
    
I don't think this meets the requirements of the OP: Once a button is selected, re-selecting it again should revert to an unselected state. See the updates in the question. –  Peter Grill Jun 8 '12 at 18:42
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.