[latex3-commits] [git/LaTeX3-latex3-pdfresources] testradio: test in unison (44d0488)

Ulrike Fischer fischer at troubleshooting-tex.de
Sat Apr 2 15:28:06 CEST 2022


Repository : https://github.com/latex3/pdfresources
On branch  : testradio
Link       : https://github.com/latex3/pdfresources/commit/44d04885d8e580dea09f00b829c204b6d4a081bb

>---------------------------------------------------------------

commit 44d04885d8e580dea09f00b829c204b6d4a081bb
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Sat Apr 2 15:28:06 2022 +0200

    test in unison


>---------------------------------------------------------------

44d04885d8e580dea09f00b829c204b6d4a081bb
 .gitignore                   |  2 ++
 experiments/radiobuttons.tex | 22 ++++++++++++++++++++++
 l3pdffield-radiobutton.dtx   | 18 ++++++++++++++----
 3 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/.gitignore b/.gitignore
index b3649df..b9e1b23 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,3 +21,5 @@ failures.txt
 resave.bat
 *.zip
 *.atfi
+*.prj
+*.bak
diff --git a/experiments/radiobuttons.tex b/experiments/radiobuttons.tex
index a0ef4cc..3a11be3 100644
--- a/experiments/radiobuttons.tex
+++ b/experiments/radiobuttons.tex
@@ -63,4 +63,26 @@
  \end{tabular}
  \ExplSyntaxOff
 
+
+ \ExplSyntaxOn
+ \bool_set_false:N \l__pdffield_radio_unison_bool
+ 
+ \begin{tabular}{ccc}
+ \pdffield_radio:n{setfieldflags=radiosinunison,name=C,value=Bär,appearance=pdffield/bear,width=\box_wd:N\l_pdffield_bear_box,height=\box_ht:N\l_pdffield_bear_box}&
+ \pdffield_radio:n{name=C,value=Sieglinde,default,appearance=pdffield/hippo,width=\box_wd:N\l_pdffield_hippo_box,height=\box_ht:N\l_pdffield_hippo_box}&
+ \pdffield_radio:n{name=C,value=Duck,appearance=pdffield/duck,width=\box_wd:N\l_pdffield_duck_box,height=\box_ht:N\l_pdffield_duck_box}\\[1ex]
+ \pdffield_radio:n{name=C,value=Bär}&
+ \pdffield_radio:n{name=C,value=Sieglinde}&
+ \pdffield_radio:n{name=C,value=Duck}
+ \end{tabular}
+\par 
+ \begin{tabular}{ccc}
+ \pdffield_radio:n{unsetfieldflags=radiosinunison,name=D,value=Bär,appearance=pdffield/bear,width=\box_wd:N\l_pdffield_bear_box,height=\box_ht:N\l_pdffield_bear_box}&
+ \pdffield_radio:n{name=D,default,value=Sieglinde,appearance=pdffield/hippo,width=\box_wd:N\l_pdffield_hippo_box,height=\box_ht:N\l_pdffield_hippo_box}&
+ \pdffield_radio:n{name=D,value=Duck,appearance=pdffield/duck,width=\box_wd:N\l_pdffield_duck_box,height=\box_ht:N\l_pdffield_duck_box}\\[1ex]
+ \pdffield_radio:n{name=D,value=Bär}&
+ \pdffield_radio:n{name=D,value=Sieglinde}&
+ \pdffield_radio:n{name=D,value=Duck}
+ \end{tabular}
+ \ExplSyntaxOff
 \end{document} 
\ No newline at end of file
diff --git a/l3pdffield-radiobutton.dtx b/l3pdffield-radiobutton.dtx
index 9056e46..46cf3e9 100644
--- a/l3pdffield-radiobutton.dtx
+++ b/l3pdffield-radiobutton.dtx
@@ -573,6 +573,8 @@
 \bool_new:N  \l_@@_radio_default_bool
 \int_new:N \l_@@_radio_value_num_int
 \tl_new:N  \l_@@_radio_appearance_code_tl
+\bool_new:N \l_@@_radio_unison_bool % if true use same name (e.g. /1) for same value
+\bool_set_true:N \l_@@_radio_unison_bool
 %    \end{macrocode}
 % \end{variable}
 %
@@ -738,10 +740,12 @@
 %    \end{macrocode}
 %  Retrieve the number for the label
 %    \begin{macrocode}
-    \int_zero:N \l_@@_radio_value_num_int
-    \exp_args:Nc
-    \seq_map_inline:Nn { g_@@_radio_opt_ \l_@@_fieldID_tl _seq }
-     {
+  \bool_if:NTF \l_@@_radio_unison_bool
+    {
+     \int_zero:N \l_@@_radio_value_num_int
+     \exp_args:Nc
+     \seq_map_inline:Nn { g_@@_radio_opt_ \l_@@_fieldID_tl _seq }
+      {
        \str_if_eq:nVTF { ##1 } \l_@@_radio_value_tl
         {
           \seq_map_break:
@@ -749,12 +753,18 @@
         {
           \int_incr:N \l_@@_radio_value_num_int
         }
+      }
+     }
+     {
+       \int_set:Nn \l_@@_radio_value_num_int
+         {\seq_count:c { g_@@_radio_opt_ \l_@@_fieldID_tl _seq } -1 }
      }
      \bool_if:NT\l_@@_radio_default_bool
       {
         \exp_args:Ne
         \ref_label:nn{\l_@@_fieldID_tl}{pdfradioindex}
       }
+
 %    \end{macrocode}
 % Annotations with the default value are set to on, the rest to off
 %    \begin{macrocode}





More information about the latex3-commits mailing list.