[latex3-commits] [git/LaTeX3-latex3-pdfresources] radiobuttons: working on value/default (499f861)

Ulrike Fischer fischer at troubleshooting-tex.de
Tue May 25 19:49:09 CEST 2021


Repository : https://github.com/latex3/pdfresources
On branch  : radiobuttons
Link       : https://github.com/latex3/pdfresources/commit/499f8610d56e55b279d933c9b67ea5804f0ecb09

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

commit 499f8610d56e55b279d933c9b67ea5804f0ecb09
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Tue May 25 19:49:09 2021 +0200

    working on value/default


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

499f8610d56e55b279d933c9b67ea5804f0ecb09
 info/donotindex.tex      |  1 +
 l3pdffield-textfield.dtx | 14 ++++++++++++--
 l3pdffield.dtx           | 45 ++++++++++++++++++++++++++++++++++++++++-----
 3 files changed, 53 insertions(+), 7 deletions(-)

diff --git a/info/donotindex.tex b/info/donotindex.tex
index 529d41c..7842e2c 100644
--- a/info/donotindex.tex
+++ b/info/donotindex.tex
@@ -39,6 +39,7 @@
 \msg_warning:nn
 \msg_warning:nnn
 \msg_warning:nnnnn
+\msg_info:nnn
 \NeedsTeXFormat
 \normalsize
 \pdf_name_from_unicode_e:n
diff --git a/l3pdffield-textfield.dtx b/l3pdffield-textfield.dtx
index aca974c..eb42ab6 100644
--- a/l3pdffield-textfield.dtx
+++ b/l3pdffield-textfield.dtx
@@ -393,7 +393,7 @@
 \cs_new_protected:Npn \@@_textfield:n #1
   {
     \group_begin:
-    \cs_set_eq:NN\@@_value_handler:nN \@@_textfield_value_handler:nN
+    \cs_set_eq:NN\@@_V_handler:nN \@@_textfield_V_handler:nN
     \use:c {@@/textfield/default_appearance:}
 %    \end{macrocode}
 % Setting up the defaults.
@@ -492,12 +492,22 @@
 %
 % \subsection{Handler}
 %    \begin{macrocode}
-\cs_new_protected:Npn \@@_textfield_value_handler:nN #1#2
+\cs_new_protected:Npn \@@_textfield_V_handler:nN #1#2
   {
      \pdf_string_from_unicode:nnN {utf8/string}{#1}#2
   }
 %    \end{macrocode}
 %
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_textfield_value_handler:n #1
+  {
+    \keys_set:nn{pdffield}{V={#1}
+  }
+\cs_new_protected:Npn \@@_textfield_default_handler:n #1
+  {
+    \keys_set:nn{pdffield}{DV={#1}
+  }
+%    \end{macrocode}
 % \subsection{user commands}
 % \begin{macro}{\pdffield_textfield:n}
 %    \begin{macrocode}
diff --git a/l3pdffield.dtx b/l3pdffield.dtx
index 2b3b06e..0b8b973 100644
--- a/l3pdffield.dtx
+++ b/l3pdffield.dtx
@@ -325,6 +325,18 @@
 % \end{syntax}
 % This allows to set default keys for a text field.
 % \end{function}
+%
+% \section{Special keys}
+%
+% \begin{function}{value,default}
+% \begin{syntax}
+% |value|  =\Arg{value}\\
+% |default|=\Arg{value}
+% \end{syntax}
+% These two keys pass the value to a handler which can be redefined.
+% Their exact behaviour depends on field type. Please check their documentation.
+% \end{function}
+%
 % \section{Field Keys}
 %
 % Table~\ref{tab:fieldkeys} summarize the keys which can be used.
@@ -337,7 +349,7 @@
 % \begin{tabular}{>{\ttfamily}lllll}
 % \toprule
 % key      & value      & required & inheritable &remark\\\midrule
-% parent   & field ID & for non-root fields &     \\
+% parent   & field ID   & for non-root fields &     \\
 % style    & style name &                   & defined with |create-style| \\
 % T, name        & string   & mostly   &             \\
 % TU, altname       & string   &          &             \\
@@ -810,6 +822,7 @@
 % ,\msg_new:nnn
 % ,\msg_warning:nn
 % ,\msg_warning:nnn
+% ,\msg_info:nnn
 % ,\msg_warning:nnnnn
 % ,\NeedsTeXFormat
 % ,\pdf_name_from_unicode_e:n
@@ -933,6 +946,10 @@
     The~parent~field~'#1'~doesn't~exist\\
     Create~it~with~\tl_to_str:n{\pdffield_field:nn}
   }
+\msg_new:nnn {pdffield}{key-ignored}
+  {
+    key~`#1`~has~no~function~and~is~ignored
+  }
 %    \end{macrocode}
 
 % An auxiliary command to disable some keys
@@ -1195,12 +1212,12 @@
 % when the field is created. A new name means a new field.
 % The other names can only be set when the field is created,
 % so we put them in the field group.
-%  \begin{macro}{\@@_value_handler:nN}
+%  \begin{macro}{\@@_V_handler:nN}
 %  Values (V and DV) need different handling in the various field types. So
 %  it uses a handler which can be redefined locally. By default it simply stores
 %  the value in a tl var.
 %    \begin{macrocode}
-\cs_new_protected:Npn \@@_value_handler:nN #1#2
+\cs_new_protected:Npn \@@_V_handler:nN #1#2
   {
     \tl_set:Nn #2 {#1}
   }
@@ -1294,7 +1311,7 @@
            \pdfdict_remove:nn { l_@@/field }{V}
          }
          {
-           \@@_value_handler:nN{#1}\l_@@_tmpa_str
+           \@@_V_handler:nN{#1}\l_@@_tmpa_str
            \pdfdict_put:nnx { l_@@/field }{V}{ \l_@@_tmpa_str }
          }
      }
@@ -1306,7 +1323,7 @@
            \pdfdict_remove:nn { l_@@/field }{DV}
          }
          {
-           \@@_value_handler:nN{#1}\l_@@_tmpa_str
+           \@@_V_handler:nN{#1}\l_@@_tmpa_str
            \pdfdict_put:nnx { l_@@/field }{DV}{ \l_@@_tmpa_str }
          }
      }
@@ -1856,6 +1873,24 @@
   }
 %    \end{macrocode}
 % \end{macro}
+% \section{Value keys}
+% \begin{macro}{value,default,\@@_value_handler:n,\@@_default_handler:n}
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_value_handler:n #1
+  {
+    \msg_info:nnn {pdffield}{key-ignored}{value}
+  }
+\cs_new_protected:Npn \@@_default_handler:n #1
+  {
+    \msg_info:nnn {pdffield}{key-ignored}{default}
+  }
+\keys_define:nn {pdffield}
+  {
+     value   .code:n = { \@@_value_handler:n {#1} }
+    ,default .code:n = { \@@_default_handler:n {#1}}
+  }
+%    \end{macrocode}
+% \end{macro}
 %    \begin{macrocode}
 %</package>
 %    \end{macrocode}





More information about the latex3-commits mailing list.