[latex3-commits] [git/LaTeX3-latex3-pdfresources] textfields: change appearance implementation (2aadcc6)

Ulrike Fischer fischer at troubleshooting-tex.de
Mon May 10 14:03:45 CEST 2021


Repository : https://github.com/latex3/pdfresources
On branch  : textfields
Link       : https://github.com/latex3/pdfresources/commit/2aadcc6a96a5a21ff0f212fd0ecc28444fd9e3ab

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

commit 2aadcc6a96a5a21ff0f212fd0ecc28444fd9e3ab
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Mon May 10 14:03:45 2021 +0200

    change appearance implementation


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

2aadcc6a96a5a21ff0f212fd0ecc28444fd9e3ab
 l3pdffield-checkbox.dtx | 38 ++++---------------------
 l3pdffield.dtx          | 73 ++++++++++++++++++++++++++++++++++++++-----------
 2 files changed, 62 insertions(+), 49 deletions(-)

diff --git a/l3pdffield-checkbox.dtx b/l3pdffield-checkbox.dtx
index cf82b9a..c3c0ed8 100644
--- a/l3pdffield-checkbox.dtx
+++ b/l3pdffield-checkbox.dtx
@@ -101,7 +101,7 @@
 % \end{syntax}
 % This creates a checkbox to check and uncheck. The list of allowed keys is described below.
 % The \meta{key val list} should at least set the name, without it the default name
-% checkbox is used. Checkboxes with the same
+% |checkbox| is used. Checkboxes with the same
 % name belong to the same field and are checked and unchecked together. The default appearance
 % is a quadratic frame with a \cs{texttimes} in it for the checked case.
 % The default appearance is setup at the first use and will use the font family
@@ -111,10 +111,9 @@
 %
 % \subsection{Keys}
 %
-% The new checkbox commands accept all field and annot keys from l3pdffield.
+% The new checkbox command accept all field and annot keys from l3pdffield.
 % A few keys are disabled or are forced to specific values.
-% A number of keys have more user friendly alias names, which roughly follow the
-% naming used in hyperref for the analog feature. Some keys have a more checkbox specific
+% Some keys have a more checkbox specific
 % behaviour or have other defaults than with the basic commands. Additionally there
 % are a small number of keys specific to a checkbox.
 %
@@ -326,6 +325,7 @@
   {
     \group_begin:
     \use:c {@@/checkbox/default_appearances:}
+    \cs_set_eq:NN\@@_appearance_handler:nnn \@@_checkbox_appearance_handler:nnn
 %    \end{macrocode}
 % Setting up the defaults.
 %    \begin{macrocode}
@@ -345,9 +345,6 @@
     \@@_key_disable:nnn{checkbox}{V}{checked}
     \@@_key_disable:nnn{checkbox}{DV}{checked}
     \@@_key_disable:nnn{checkbox}{AS}{checked}
-    \@@_key_disable:nnn{checkbox}{AP/N}{appearance}
-    \@@_key_disable:nnn{checkbox}{AP/R}{rollover-appearance}
-    \@@_key_disable:nnn{checkbox}{AP/D}{down-appearance}
     \keys_set:nn { pdffield }{@@/preset/checkbox,#1}
     \keys_set:nn { pdffield }
       {
@@ -400,7 +397,7 @@
 %    \end{macrocode}
 % \begin{macro}{\@@_checkbox_appearance:nnn}
 %    \begin{macrocode}
-\cs_new_protected:Npn \@@_checkbox_appearance:nnn #1 #2 #3 %name, type, text
+\cs_new_protected:Npn \@@_checkbox_appearance_handler:nnn #1 #2 #3 %name, type, text
   {
     \pdfxform_if_exist:nTF {  #1/Yes }
       {
@@ -420,32 +417,7 @@
          \msg_error:nnnn{pdffield}{appearance-missing}{#1}{#3}
       }
    }
-\keys_define:nn { pdffield  }
-  {
-    appearance .code:n = %value is a name of an appearance
-      {
-        \@@_checkbox_appearance:nnn {#1}{N}{normal}
-      },
-    ,appearance .groups:n  = {checkbox}
-  }
 
-\keys_define:nn { pdffield  }
-  {
-    rollover-appearance .code:n = %value is a name of an appearance
-      {
-        \@@_checkbox_appearance:nnn {#1}{R}{rollover}
-      },
-    ,rollover-appearance .groups:n  = {checkbox}
-  }
-
-\keys_define:nn { pdffield  }
-  {
-    down-appearance .code:n = %value is a name of an appearance
-      {
-        \@@_checkbox_appearance:nnn {#1}{D}{down}
-      },
-    ,down-appearance .groups:n  = {checkbox}
-  }
 %    \end{macrocode}
 %
 % \end{macro}
diff --git a/l3pdffield.dtx b/l3pdffield.dtx
index 33bc708..f20f01b 100644
--- a/l3pdffield.dtx
+++ b/l3pdffield.dtx
@@ -1269,25 +1269,66 @@
     }
   ,AS .groups:n = annot
  }
-\cs_set_protected:Npn \@@_tmpa:n #1
-  {
-   \keys_define:nn { pdffield }
+\cs_new_protected:Npn \@@_appearance_handler:nnn #1#2#3
+ {
+   \pdfxform_if_exist:nTF {  #1 }
      {
-       AP/#1 .code:n =
-        {
-          \tl_if_empty:nTF {##1}
-           {
-             \pdfannot_dict_remove:nn { widget/AP }
-           }
-           {
-             \pdfannot_dict_put:nnx {widget/AP}{#1}{##1}
-           }
-        }
-      ,AP/#1 .groups:n = annot
+       \pdfannot_dict_put:nnx {widget}{AP/#2}
+         {
+           \pdfxform_ref:n {#1}
+         }
      }
+     {
+       \msg_error:nnnn{pdffield}{appearance-missing}{#1}{#3}
+     }
+ }
+\keys_define:nn { pdffield }
+  {
+    AP/N .code:n =
+      {
+        \tl_if_empty:nTF {#1}
+          {
+            \pdfannot_dict_remove:nn { widget/AP }{N}
+          }
+          {
+            \@@_appearance_handler:nnn {#1}{N}{normal}
+          }
+        }
+   ,AP/N .groups:n = annot
+   ,appearance .meta:n = {AP/N={#1}}
   }
-\clist_map_inline:nn {N,R,D}
-  { \@@_tmpa:n {#1} }
+\keys_define:nn { pdffield }
+  {
+    AP/R .code:n =
+      {
+        \tl_if_empty:nTF {#1}
+          {
+            \pdfannot_dict_remove:nn { widget/AP }{R}
+          }
+          {
+             \@@_appearance_handler:nnn {#1}{R}{rollover}
+          }
+        }
+   ,AP/R .groups:n = annot
+   ,rollover-appearance .meta:n = {AP/R={#1}}
+  }
+\keys_define:nn { pdffield }
+  {
+    AP/D .code:n =
+      {
+        \tl_if_empty:nTF {#1}
+          {
+            \pdfannot_dict_remove:nn { widget/AP }{D}
+          }
+          {
+             \@@_appearance_handler:nnn {#1}{D}{rollover}
+          }
+        }
+   ,AP/D .groups:n = annot
+   ,down-appearance .meta:n = {AP/D={#1}}
+  }
+
+
 
 \cs_set_protected:Npn \@@_tmpa:n #1
  {





More information about the latex3-commits mailing list.