[latex3-commits] [latex3/pdfresources] use-properties: use property if exist in radio buttons (fc853d8)
github at latex-project.org
github at latex-project.org
Wed Sep 13 00:53:04 CEST 2023
Repository : https://github.com/latex3/pdfresources
On branch : use-properties
Link : https://github.com/latex3/pdfresources/commit/fc853d804d765b203a1006fe9bbd172540e87baa
>---------------------------------------------------------------
commit fc853d804d765b203a1006fe9bbd172540e87baa
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Wed Sep 13 00:53:04 2023 +0200
use property if exist in radio buttons
>---------------------------------------------------------------
fc853d804d765b203a1006fe9bbd172540e87baa
l3pdffield-radiobutton.dtx | 42 +++++++++++++++++++++++++++++-------------
1 file changed, 29 insertions(+), 13 deletions(-)
diff --git a/l3pdffield-radiobutton.dtx b/l3pdffield-radiobutton.dtx
index b9737a3..0f8a4bf 100644
--- a/l3pdffield-radiobutton.dtx
+++ b/l3pdffield-radiobutton.dtx
@@ -669,15 +669,32 @@
%
%\subsection{Creating the field}
% We need to retrieve the index of the default through a
-% label, so we need an ref attribute:
+% label, so we need an ref attribute or with newer LaTeX
+% a property:
%
% \begin{macrocode}
-\ref_attribute_gset:nnnn {pdfradioindex}{0}{now}
- {
- \int_use:N\l_@@_radio_value_num_int
- }
-\cs_generate_variant:Nn \ref_label:nn {V}
-\cs_generate_variant:Nn \ref_value:nn {V}
+\cs_if_exist:NTF \property_new:nnnn
+ {
+ \property_new:nnnn {pdfradioindex}{now}
+ {0}
+ {
+ \int_use:N\l_@@_radio_value_num_int
+ }
+ \cs_new_eq:NN \@@_property_record:nn \property_record:nn
+ \cs_new_eq:NN \@@_property_ref:nn \property_ref:nn
+ }
+ {
+ \ref_attribute_gset:nnnn {pdfradioindex}{0}{now}
+ {
+ \int_use:N\l_@@_radio_value_num_int
+ }
+ \cs_new_eq:NN \@@_property_record:nn \ref_label:nn
+ \cs_new_eq:NN \@@_property_ref:nn \ref_value:nn
+ }
+
+ \cs_generate_variant:Nn \@@_property_record:nn {V}
+ \cs_generate_variant:Nn \@@_property_ref:nn {V}
+
% \end{macrocode}
% A field should be created if the name doesn't exist yet
% \begin{macro}{\@@_radio_field:n}
@@ -702,8 +719,8 @@
% \end{macrocode}
% The default value is retrieved through a label:
% \begin{macrocode}
- \pdfdict_put:nnx { l_@@/field }{V} { /\ref_value:nn{#1}{pdfradioindex} }
- \pdfdict_put:nnx { l_@@/field }{DV} { /\ref_value:nn{#1}{pdfradioindex} }
+ \pdfdict_put:nnx { l_@@/field }{V} { /\@@_property_ref:nn{#1}{pdfradioindex} }
+ \pdfdict_put:nnx { l_@@/field }{DV} { /\@@_property_ref:nn{#1}{pdfradioindex} }
% \end{macrocode}
% now we create the field and set it as parent for the following annotation.
% \begin{macrocode}
@@ -801,8 +818,7 @@
}
\bool_if:NT\l_@@_radio_default_bool
{
- \exp_args:Ne
- \ref_label:nn{\l_@@_fieldID_tl}{pdfradioindex}
+ \@@_property_record:Vn\l_@@_fieldID_tl{pdfradioindex}
}
% \end{macrocode}
@@ -810,9 +826,9 @@
% \begin{macrocode}
\int_compare:nNnTF { \l_@@_radio_value_num_int } =
{
- \ref_value:Vn\l_@@_fieldID_tl{pdfradioindex}
+ \@@_property_ref:Vn\l_@@_fieldID_tl{pdfradioindex}
}
- { \pdfannot_dict_put:nnx {widget}{AS}{/\ref_value:Vn\l_@@_fieldID_tl{pdfradioindex}} }
+ { \pdfannot_dict_put:nnx {widget}{AS}{/\@@_property_ref:Vn\l_@@_fieldID_tl{pdfradioindex}} }
{ \pdfannot_dict_put:nnx {widget}{AS}{/Off} }
% \end{macrocode}
% Now we set the appearances, if no key has been use we take the default.
More information about the latex3-commits
mailing list.