[latex3-commits] [git/LaTeX3-latex3-pdfresources] textfields: storing (8ebb860)

Ulrike Fischer fischer at troubleshooting-tex.de
Sun May 9 00:23:19 CEST 2021


Repository : https://github.com/latex3/pdfresources
On branch  : textfields
Link       : https://github.com/latex3/pdfresources/commit/8ebb8604b617aca7a7c824d22f5cac60e1761978

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

commit 8ebb8604b617aca7a7c824d22f5cac60e1761978
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Sun May 9 00:23:19 2021 +0200

    storing


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

8ebb8604b617aca7a7c824d22f5cac60e1761978
 l3pdffield-checkbox.dtx | 202 ++++++++++++++++--------------------------------
 l3pdffield.dtx          | 184 ++++++++++++++++++++++++++++++++++---------
 2 files changed, 214 insertions(+), 172 deletions(-)

diff --git a/l3pdffield-checkbox.dtx b/l3pdffield-checkbox.dtx
index 1296923..ec5fe24 100644
--- a/l3pdffield-checkbox.dtx
+++ b/l3pdffield-checkbox.dtx
@@ -45,11 +45,11 @@
 %    ]{Checkboxkey}{checkboxkey}
 % \providecommand\hook[1]{\texttt{#1}}
 % \ExplSyntaxOn
-% \pdffield_store_appearance:nn {bear/Yes}
+% \pdffield_store_appearance:nn {pdffield/bear/Yes}
 %  {
 %    \tikz\bear\bearwear[shirt=red,body~deco={\node[font=\tiny\bfseries,white]~at~(beartummy){Yes};}];
 %  }
-% \pdffield_store_appearance:nn {bear/Off}
+% \pdffield_store_appearance:nn {pdffield/bear/Off}
 %  {
 %   \tikz\bear\bearwear[body~deco={\node[font=\tiny\bfseries,white]~at~(beartummy){Off};}];
 %  }
@@ -89,7 +89,9 @@
 % \end{itemize}
 % \section{Checkboxes}
 % Click me:
-% \ExplSyntaxOn\pdffield_checkbox:n{name=bear,appearance=bear,width=23pt,height=30pt,depth=10pt}\ExplSyntaxOff
+% \ExplSyntaxOn
+%  \pdffield_checkbox:n{name=bear,appearance=pdffield/bear,width=23pt,height=30pt,depth=10pt}
+% \ExplSyntaxOff
 %
 % \bigskip
 % \subsection{Commands}
@@ -98,9 +100,12 @@
 %  \cs{pdffield_checkbox:n}\Arg{key val list}
 % \end{syntax}
 % This creates a checkbox to check and uncheck. The list of allowed keys is described below.
-% Typically the \meta{key val list} should at least set the name. Checkboxes with the same
+% The \meta{key val list} should at least set the name, without it the default name
+% 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
+% active at that time.
 % \end{function}
 %
 % \subsection{Keys}
@@ -238,31 +243,21 @@
 %    \end{macrocode}
 % \subsection{Variables}
 %    \begin{macrocode}
-\bool_new:N \l_@@_checkbox_newfield_bool
 %    \end{macrocode}
 % \subsection{Messages}
 %    \begin{macrocode}
 %    \end{macrocode}
-
-
 % \subsection{Appearances}
-% We don't try to force a size or content here.
 % The default appearances are a cross (\cs{texttimes}),
 % Every appearance should have two versions and follow the naming
-% checkbox/\meta{name}/Yes and checkbox/\meta{name}/Off.
-% TODO check if one delay the creation to a sensible place
-% (and don't forget that the appearance key sets an initial
-% value)
-%  \begin{macro}{\pdffield_store_appearance:nn,\@@_store_default_appearances:}
+% module/\meta{name}/Yes and module/\meta{name}/Off.
+%  \begin{macro}{@@/checkbox/default_appearances:}
+%  This defines the standard appearance. It is setup at the first
+%  use of a checkbox, and will adapt to the font family in use then.
 %    \begin{macrocode}
-\cs_new_protected:Npn \pdffield_store_appearance:nn #1 #2
+\cs_new_protected:cn {@@/checkbox/default_appearances:}
   {
-     \pdfxform_new:nnn {@@_#1}{}{#2}
-  }
-
-\cs_new_protected:Nn \@@_store_default_appearances:
-  {
-     \pdffield_store_appearance:nn {checkbox/default/Yes}
+     \pdffield_store_appearance:nn {pdffield/checkbox/default/Yes}
        {
          \normalsize
          \fboxsep 0pt
@@ -270,7 +265,7 @@
            [ \dim_eval:n { \box_ht:N\strutbox+\box_dp:N\strutbox } ]
            { \texttimes \strut }
        }
-     \pdffield_store_appearance:nn {checkbox/default/Off}
+     \pdffield_store_appearance:nn {pdffield/checkbox/default/Off}
        {
          \normalsize
          \fboxsep 0pt
@@ -278,60 +273,51 @@
            [ \dim_eval:n { \box_ht:N\strutbox+\box_dp:N\strutbox } ]
            { \phantom{\texttimes} \strut }
        }
+    \cs_gset_eq:cN {@@/checkbox/default_appearances:} \prg_do_nothing:
   }
-
-\@@_store_default_appearances:
 %    \end{macrocode}
 % \end{macro}
-% We define a dictionary for the AP content, so that we can add R and D too
-%    \begin{macrocode}
-\pdfdict_new:n   {l_@@/checkbox/annot/AP}
-%    \end{macrocode}
+%
 %\subsection{Creating the field}
-% A field should be created if the name doesn't exist, or
-% if it is forced
+% A field should be created if the name doesn't exist
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_checkbox_field:n #1 %name
   {
-    \bool_if:nT
-      {
-        \l_@@_checkbox_newfield_bool
-        ||
-        ! \pdf_object_if_exist_p:n {@@/field/#1}
-      }
+    \pdf_object_if_exist:nF {@@/field/@@/checkbox/#1}
       {
         \@@_field:n { #1 }
       }
-    \keys_set:nn {pdffield/annot}{parent=#1}
+    \keys_set:nn {pdffield}{parent=@@/checkbox/#1}
   }
 \cs_generate_variant:Nn \@@_checkbox_field:n {V}
 %    \end{macrocode}
+%
 % \subsection{Assembling the checkbox}
 % \begin{macro}{\@@_checkbox:n}
 %    \begin{macrocode}
-%initial width??
 \cs_new_protected:Npn \@@_checkbox:n #1
   {
     \group_begin:
-    \keys_set_known:nnN {pdffield / checkbox }
-      {
+    \use:c {@@/checkbox/default_appearances:}
+    \keys_set:nn {pdffield}
+     {
         name=checkbox,
-        appearance = checkbox/default,
-        width =\normalbaselineskip,
-        height=\normalbaselineskip,
-        #1
-      }\l_@@_tmpa_keys_tl
-    \keys_define:nn {pdffield / field }
+        appearance = pdffield/checkbox/default,
+        width  = \normalbaselineskip,
+        height = \normalbaselineskip,
+     }
+    %\keys_set_groups:nnV {pdffield }{checkbox}\l_@@_checkbox_preset_tl  
+    \keys_set_groups:nnn {pdffield }{checkbox}{#1}
+    \keys_define:nn {pdffield  }
      {
-       V  .undefine: , DV .undefine:
+       V  .undefine: , DV .undefine: , AS .undefine:,
+       AP/N .undefine: , AP/R .undefine: , AP/D .undefine:,
      }
-    \keys_define:nn {pdffield / annot }
+    \keys_set:nn {pdffield }
      {
-       AS .undefine:
      }
-    \keys_set_known:nVN {pdffield / field } \l_@@_tmpa_keys_tl \l_@@_tmpa_keys_tl
-    \keys_set_known:nVN {pdffield / annot } \l_@@_tmpa_keys_tl \l_@@_tmpa_keys_tl
-    \keys_set:nn{pdffield/field}
+    \keys_set:nV {pdffield } \l_@@_tmpa_keys_tl
+    \keys_set:nn{ pdffield }
       {
         ,unsetFf={Radio,Pushbutton}
         ,FT= Btn
@@ -344,69 +330,44 @@
   }
 %    \end{macrocode}
 % \end{macro}
+%
 % \subsection{Keys}
 % Most keys are inherited simply the ones from the generic field and annot keys.
-% The main name should not be empty. A new name means a new field.
-% The other names can only be set when the field is created. Perhaps some filter
-% to warn could be useful?
+% A key to decide if the box is initially checked or not.
+% We stay in the same family so that we can build a style.
 %    \begin{macrocode}
-\keys_define:nn { pdffield / checkbox  }
-  {
-    ,name .meta:nn          = {pdffield/field}{T=#1}
-    ,name .value_required:n = true
-    ,name .initial:n        = checkbox
-    ,altname .meta:nn       = {pdffield/field}{TU=#1}
-    ,mappingname .meta:nn   = {pdffield/field}{TM=#1}
-    ,parent .tl_set:N = \l_@@_currentparent_tl
-  }
-%    \end{macrocode}
-
-% A key to decide if the Box is initially checked or not
-%    \begin{macrocode}
-\keys_define:nn { pdffield / checkbox }
+\keys_define:nn { pdffield  }
  {
    ,checked .choice:
    ,checked / false .code:n =
      {
-       \keys_set:nn {pdffield/field}{V=/Off,DV=/Off}
-       \keys_set:nn {pdffield/annot}{AS=Off}
+       \keys_set:nn {pdffield }{V=/Off,DV=/Off,AS=Off}
      }
    ,checked / true .code:n =
      {
-       \keys_set:nn {pdffield/field}{V=/Yes,DV=/Yes}
-       \keys_set:nn {pdffield/annot}{AS=Yes}
+       \keys_set:nn {pdffield}{V=/Yes,DV=/Yes,AS=Yes}
      }
    ,checked .default:n = {true}
    ,checked .initial:n = {false}
+   ,checked .groups:n  = {checkbox}
  }
 %    \end{macrocode}
-% Flags. We don't add lots of individual keys but mapped the key names directly
+%
 %    \begin{macrocode}
-\keys_define:nn { pdffield / checkbox }
-  {
-    ,setfieldflags .meta:nn =
-      { pdffield/field }{setFf={#1}}
-    ,unsetfieldflags .meta:nn =
-      { pdffield/field }{setFf={#1}}
-    ,setannotflags .meta:nn =
-      { pdffield/annot }{setF={#1}}
-    ,unsetannotflags .meta:nn =
-      { pdffield/annot }{unsetF={#1}}
-  }
 
-\keys_define:nn { pdffield / checkbox }
+\keys_define:nn { pdffield  }
   {
     appearance .code:n = %value is a name of an appearance
       {
-        \pdfxform_if_exist:nTF {  @@_#1/Yes }
+        \pdfxform_if_exist:nTF {  #1/Yes }
           {
-            \keys_set:nn{pdffield/annot}
+            \keys_set:nn{ pdffield }
               {
                AP/N =
                 {
                   <<
-                    /Yes ~ \pdfxform_ref:n { @@_#1/Yes}
-                    /Off ~ \pdfxform_ref:n { @@_#1/Off}
+                    /Yes ~ \pdfxform_ref:n { #1/Yes}
+                    /Off ~ \pdfxform_ref:n { #1/Off}
                   >>
                 }
               }
@@ -415,21 +376,22 @@
             \msg_error:nnnn{pdffield}{appearance-missing}{#1}{normal}
           }
       },
+    ,appearance .groups:n  = {checkbox}
   }
 
-\keys_define:nn { pdffield / checkbox }
+\keys_define:nn { pdffield  }
   {
     rollover-appearance .code:n = %value is a name of an appearance
       {
-        \pdfxform_if_exist:nTF {  @@_#1/Yes }
+        \pdfxform_if_exist:nTF {  #1/Yes }
           {
-            \key_set:nn{pdffield/annot}
+            \key_set:nn{ pdffield }
               {
                AP/R =
                 {
                   <<
-                    /Yes ~ \pdfxform_ref:n { @@_#1/Yes}
-                    /Off ~ \pdfxform_ref:n { @@_#1/Off}
+                    /Yes ~ \pdfxform_ref:n { #1/Yes}
+                    /Off ~ \pdfxform_ref:n { #1/Off}
                   >>
                 }
               }
@@ -438,21 +400,22 @@
             \msg_error:nnnn{pdffield}{appearance-missing}{#1}{normal}
           }
       },
+    ,rollover-appearance .groups:n  = {checkbox}
   }
 
-\keys_define:nn { pdffield / checkbox }
+\keys_define:nn { pdffield  }
   {
     down-appearance .code:n = %value is a name of an appearance
       {
-        \pdfxform_if_exist:nTF {  @@_#1/Yes }
+        \pdfxform_if_exist:nTF {  #1/Yes }
           {
-            \key_set:nn{pdffield/annot}
+            \key_set:nn{ pdffield }
               {
                AP/D =
                 {
                   <<
-                    /Yes ~ \pdfxform_ref:n { @@_#1/Yes}
-                    /Off ~ \pdfxform_ref:n { @@_#1/Off}
+                    /Yes ~ \pdfxform_ref:n { #1/Yes}
+                    /Off ~ \pdfxform_ref:n { #1/Off}
                   >>
                 }
               }
@@ -461,51 +424,16 @@
             \msg_error:nnnn{pdffield}{appearance-missing}{#1}{normal}
           }
       },
+    ,down-appearance .groups:n  = {checkbox}
   }
 %    \end{macrocode}
 %
-%  Keys for the AA dictionary. They all trigger javascript option.
-%
-%    \begin{macrocode}
-\cs_set_protected:Npn \@@_tmpa:nn #1 #2
-  {
-    \keys_define:nn { pdffield / checkbox }
-      {
-         #1 .meta:nn =
-           {pdffield/field}{#2={##1}},
-      }
-  }
-\@@_tmpa:nn {keystroke}{K}
-\@@_tmpa:nn {format}   {F}
-\@@_tmpa:nn {validate} {V}
-\@@_tmpa:nn {calculate}{C}
-
-\cs_set_protected:Npn \@@_tmpa:nn #1 #2
-  {
-    \keys_define:nn { pdffield / checkbox }
-      {
-         #1 .meta:nn =
-           {pdffield/annot}{#2={##1}},
-      }
-  }
-
-\@@_tmpa:nn {onfocus}  {Fo}
-\@@_tmpa:nn {onblur}   {Bl}
-\@@_tmpa:nn {onmousedown}{D}
-\@@_tmpa:nn {onmouseup}{U}
-\@@_tmpa:nn {onenter}  {E}
-\@@_tmpa:nn {onexit}   {X}
-%    \end{macrocode}
 % \end{macro}
+%
 % \subsection{user commands}
-% \begin{macro}{\pdffield_checkbox:n,\pdffield_setup:nn}
+% \begin{macro}{\pdffield_checkbox:n}
 %    \begin{macrocode}
 \cs_set_eq:NN \pdffield_checkbox:n \@@_checkbox:n
-
-\cs_new_protected:Npn \pdffield_setup:nn #1 #2
- {
-   \keys_set:nn {pdffield / #1 } {#2}
- }
 %</package>
 %    \end{macrocode}
 % \end{macro}
diff --git a/l3pdffield.dtx b/l3pdffield.dtx
index 4301ef3..9f74d4b 100644
--- a/l3pdffield.dtx
+++ b/l3pdffield.dtx
@@ -268,10 +268,19 @@
 % The command also setup dictionaries to fill the |AP|, |MK| and |AA| dictionaries.
 % \end{function}
 %
+% \begin{function}{\pdffield_appearance:nn}
+% \begin{syntax}
+%  \cs{pdffield_appearance:nn}\Arg{name}\Arg{content}
+% \end{syntax}
+% This is a small wrapper around \cs{pdfxform_new:nnn} (which could be used too)
+% to create an appearance. To avoid name clashes \meta{name} should start with
+% a module part, e.g. |mymodule/appearance/cross|.
+% \end{function}
 %
 % \section{Field Keys}
 %
 % Table~\ref{tab:fieldkeys} summarize the keys which can be used.
+% A number of keys have two names, the second is normally the name used by hyperref.
 %
 % \begin{table}
 % \caption{Keys for fields}\label{tab:fieldkeys}
@@ -280,12 +289,14 @@
 % \toprule
 % key      & value      & required & inheritable &remark\\\midrule
 % parent   & field ID & for non-root fields &     \\
-% T        & string   & mostly   &             \\
-% TU       & string   &          &             \\
-% TM       & string   &          &             \\
+% T, name        & string   & mostly   &             \\
+% TU, altname       & string   &          &             \\
+% TM, mappingname       & string   &          &             \\
 % FT       & name     & terminal fields & yes  \\
-% setFf    & list of flags &     & yes\\
-% unsetFf  & list of flags &    & yes \\
+% setFf,    & list of flags &     & yes\\
+% setfieldflags\\
+% unsetFf,  & list of flags &    & yes \\
+% unsetfieldflags \\
 % V        & various   &        & yes \\
 % DV       & various   &        & yes \\
 % MaxLen   & integer   & with Comb   & yes             & only textfields\\
@@ -294,10 +305,10 @@
 % Opt      & object name &         &                  & buttons and choice fields\\
 % TI       & integer    &          &                  & list fields\\
 % I        & object name&          &                  & list fields\\
-% AA/K     & javascript \\
-% AA/F     & javascript\\
-% AA/V     & javascript\\
-% AA/C     & javascript\\
+% AA/K, keystroke     & javascript \\
+% AA/F, format     & javascript\\
+% AA/V, validate     & javascript\\
+% AA/C, calculate     & javascript\\
 % DA        & string    & yes   &   yes    & variable text \\
 % Q       & 0, 1 or 2   &          & yes   &variable text  \\
 % DS       &    &          &         & (ignored) \\
@@ -311,15 +322,15 @@
 % It will add the reference to the parent field to the |/Parent| key, and also
 % add reference of the kid as |/Kid| in the parent field.
 %
-% \DescribeFieldkey{T} This sets the partial name of the field. It shouldn't contain
+% \DescribeFieldkey{T}\DescribeFieldkey{name} This sets the partial name of the field. It shouldn't contain
 % a period, be not empty and sensibly consist of simple ascii chars.
 % It is normally required, see above. The value is passed through \cs{pdf_string_from_unicode:nnN}.
 %
-% \DescribeFieldkey{TU} This sets an alternative name for user interaction.
+% \DescribeFieldkey{TU}\DescribeFieldkey{altname} This sets an alternative name for user interaction.
 % Unlike the name field it can use unicode or periods.
 % The value is passed through \cs{pdf_string_from_unicode:nnN}
 %
-% \DescribeFieldkey{TM} This sets an alternative name for the export.
+% \DescribeFieldkey{TM}\DescribeFieldkey{mappingname} This sets an alternative name for the export.
 % The value is passed through \cs{pdf_string_from_unicode:nnN}
 %
 % \DescribeFieldkey{FT} This sets the type of the field, the value should be one of
@@ -327,7 +338,8 @@
 % The value is of relevance only for terminal fields, but it can be set in a parent
 % and then inherited.
 %
-% \DescribeFieldkey{setFf}\DescribeFieldkey{unsetFf}
+% \DescribeFieldkey{setFf}\DescribeFieldkey{setfieldflags}
+% \DescribeFieldkey{unsetFf}\DescribeFieldkey{setfieldflags}
 % This key accepts a list of flag names and then sets or unsets them, the resulting value
 % is then used with the \texttt{/Ff} key. Depending
 % on the field type some flags must be set or unset, other are optional or are ignored.
@@ -460,8 +472,8 @@
 % for checkbox for example |Yes|. If used it should typically have the same value
 % as the V and DV key of the field.
 %
-% \DescribeAnnotkey{setF}
-% \DescribeAnnotkey{unsetF}
+% \DescribeAnnotkey{setF}\DescribeAnnotkey{setannotflags}
+% \DescribeAnnotkey{unsetF}\DescribeAnnotkey{unsetannotflags}
 % These keys allow to set or unset the annot flags.  They expect a comma lists of
 % flag names. Allowed names |Invisible|, |Hidden|,
 %  |Print|, |NoZoom|,|NoRotate|, |NoView|, |ReadOnly|, |Locked|, |ToggleNoView|,
@@ -469,6 +481,8 @@
 %
 % \begin{annotkey}{AA/*}
 % * should be one of |F|, |Bl|, |D|, |U|, |E|, |X|, |PO|, |PC|, |PV|, |PI|.
+% Alias names for the first six keys are
+% |onfocus|, |onblur|, |onmousedown|, |onmouseup|, |onenter|,  |onexit|.
 % These keys adds then the respective key to the |/AA| dictionary
 % of the field annotation object.
 % Their value should be javascript code. The |/AA| dictionary
@@ -713,6 +727,21 @@
         \bitset_set_false:Nn \l_@@_F_bitset {NoView}
       }
     \pdfannot_dict_put:nnx {widget}{F}{ \bitset_to_arabic:N \l_@@_F_bitset }
+    \tl_if_empty:NF \l_@@_currentparent_tl
+      {
+         \exp_args:Ne
+         \pdf_object_if_exist:nTF { @@/field/\l_@@_currentparent_tl }
+           {
+             \pdfannot_dict_put:nnx {widget}{Parent}
+               {
+                 \exp_args:Ne
+                   \pdf_object_ref:n{@@/field/\l_@@_currentparent_tl}
+               }
+           }
+           {
+               \msg_error:nnn { pdffield }{parent-field-missing}{#1}
+           }
+       }
     \mode_leave_vertical:
     \hbox_to_wd:nn
       { \l_@@_annot_wd_dim  }
@@ -753,9 +782,10 @@
 % The other names can only be set when the field is created,
 % so we put them in the field group.
 %    \begin{macrocode}
-\keys_define:nn { pdffield /field }
+\keys_define:nn { pdffield  }
   {
     ,parent .tl_set:N = \l_@@_currentparent_tl
+    ,parent .groups:n = {field,annot}
     ,T .code:n =
       {
         \pdf_string_from_unicode:nnN {utf8/string-raw}{#1}\l_@@_tmpa_str
@@ -772,55 +802,73 @@
           }
       }
     ,T .value_required:n = true
+    ,T .groups:n = {field}
+    ,name .meta:n          = {T={#1}}
+    ,name .value_required:n = true
+    ,name .groups:n = {field}
+    ,TU .groups:n = {field}
     ,TU .code:n =
       {
         \pdf_string_from_unicode:nnN {utf8/string}{#1}\l_@@_tmpa_str
         \pdfdict_put:nnx { l_@@/field }{TU}{\l_@@_tmpa_str}
       }
     ,TU .groups:n = {field}
+    ,altname .meta:n      = {TU={#1}}
+    ,altname .groups:n = {field}
     ,TM .code:n =
       {
         \pdf_string_from_unicode:nnN {utf8/string}{#1}\l_@@_tmpa_str
         \pdfdict_put:nnx { l_@@/field }{TM}{\l_@@_tmpa_str}
       }
     ,TM .groups:n = {field}
+    ,mappingname .meta:n   = {TM={#1}}
+    ,mappingname .groups:n = {field}
     ,FT .choices:nn =
       { Btn, Tx, Ch, Sig }
       {
         \pdfdict_put:nnn { l_@@/field }{FT}{ /#1 }
       }
+    ,FT .groups:n = {field}
     ,V .code:n =
      {
        \pdfdict_put:nnx { l_@@/field }{V}{ #1 }
      }
+    ,V .groups:n = {field}
     ,DV .code:n =
      {
        \pdfdict_put:nnx { l_@@/field }{V}{ #1 }
      }
+    ,DV .groups:n = {field}
     ,MaxLen .code:n =
      {
        \pdfdict_put:nnx { l_@@/field }{MaxLen}{ #1 }
      }
+    ,MaxLen .groups:n = {field}
     ,Lock .code:n =
      {
        \pdfdict_put:nnx { l_@@/field }{Lock}{ \pdf_object_ref:n{#1} }
      }
+    ,Lock .groups:n = {field}
     ,SV .code:n =
      {
        \pdfdict_put:nnx { l_@@/field }{SV}{ \pdf_object_ref:n{#1} }
      }
+    ,SV .groups:n = {field}
     ,Opt .code:n =
      {
        \pdfdict_put:nnx { l_@@/field }{Opt}{ \pdf_object_ref:n{#1} }
      }
+    ,Opt .groups:n = {field}
     ,TI .code:n =
      {
        \pdfdict_put:nnx { l_@@/field }{TI}{ #1 }
      }
+    ,TI .groups:n = {field}
     ,I .code:n =
      {
        \pdfdict_put:nnx { l_@@/field }{I}{ \pdf_object_ref:n{#1} }
      }
+    ,I .groups:n = {field}
   }
 %    \end{macrocode}
 
@@ -836,6 +884,9 @@
            }
       }
     ,setFf .groups:n = {field}
+    ,setfieldflags .meta:nn =
+      { pdffield }{setFf={#1}}
+    ,setfieldflags .groups:n = {field}
     ,unsetFf .code:n =
       {
           \clist_map_inline:nn {#1}
@@ -844,6 +895,7 @@
            }
       }
     ,unsetFf .groups:n = {field}
+    ,unsetfieldflags .groups:n = {field}
   }
 
 %    \end{macrocode}
@@ -853,7 +905,7 @@
 %    \begin{macrocode}
 \cs_set_protected:Npn \@@_tmpa:n #1  %
   {
-    \keys_define:nn { pdffield / field }
+    \keys_define:nn { pdffield  }
       {
          AA/#1 .code:n =
            {
@@ -868,31 +920,52 @@
                   {<</S/JavaScript/JS\l_@@_tmpa_str>>}
                }
            },
+        AA/#1 .groups:n  = {field}
       }
   }
 
 \clist_map_inline:nn {K,F,V,C}{\@@_tmpa:n{#1}}
+
+\cs_set_protected:Npn \@@_tmpa:nn #1 #2
+  {
+    \keys_define:nn { pdffield  }
+      {
+         #1 .meta:nn =
+           { pdffield }{#2={##1}},
+        #1 .groups:n  = {field}
+      }
+  }
+\@@_tmpa:nn {keystroke}{K}
+\@@_tmpa:nn {format}   {F}
+\@@_tmpa:nn {validate} {V}
+\@@_tmpa:nn {calculate}{C}
+
+
 %    \end{macrocode}
 %
 %    \begin{macrocode}
-\keys_define:nn {pdffield/field}
+\keys_define:nn { pdffield }
   {
     DA .code:n =
       {
          \pdfdict_put:nnx{ l_@@_field}{DA}{(#1)}
       }
+    ,DA .groups:n = {field}
     ,Q .choices:nn = {0,1,2}
      {
        \pdfdict_put:nnn{ l_@@_field}{Q}{#1}
      }
+    ,Q .groups:n = {field}
     ,DS .code:n =
      {
        \msg_warning:nnn {pdffield}{not-implemented}{DS}
      }
+    ,DS .groups:n = {field}
     ,RV .code:n =
      {
        \msg_warning:nnn {pdffield}{not-implemented}{RV}
      }
+    ,RV .groups:n = {field}
   }
 %    \end{macrocode}
 %
@@ -904,7 +977,7 @@
 \dim_new:N \l_@@_annot_wd_dim
 \dim_new:N \l_@@_annot_dp_dim
 
-\keys_define:nn { pdffield / annot }
+\keys_define:nn { pdffield }
   {
     ,width  .dim_set:N = \l_@@_annot_wd_dim
     ,height .dim_set:N = \l_@@_annot_ht_dim
@@ -916,30 +989,22 @@
 %    \end{macrocode}
 %
 %    \begin{macrocode}
-\keys_define:nn { pdffield / annot }
+\keys_define:nn { pdffield }
  {
-   parent .code:n =
-    {
-      \tl_set:Nn \l_@@_currentparent_tl {#1}
-      \pdf_object_if_exist:nTF { @@/field/#1 }
-        {
-          \pdfannot_dict_put:nnx {widget}{Parent}{\pdf_object_ref:n{@@/field/#1}}
-        }
-        {
-          \msg_error:nnn { pdffield }{parent-field-missing}{#1}
-        }
-    }
+   %parent is defined in field
   ,AS .code:n =
     {
       \pdfannot_dict_put:nnx {widget}{AS}{\pdf_name_from_unicode_e:n{#1}}
     }
+  .AS .groups:n = annot
  }
 \cs_set_protected:Npn \@@_tmpa:n #1
   {
-   \keys_define:nn { pdffield / annot }
+   \keys_define:nn { pdffield }
      {
        AP/#1 .code:n =
         { \pdfannot_dict_put:nnx {widget/AP}{#1}{##1} }
+      ,AP/#1 .groups:n = annot
      }
   }
 \clist_map_inline:nn {N,R,D}
@@ -947,10 +1012,11 @@
 
 \cs_set_protected:Npn \@@_tmpa:n #1
  {
-   \keys_define:nn { pdffield / annot }
+   \keys_define:nn { pdffield  }
      {
        MK/#1 .code:n =
         { \pdfannot_dict_put:nnx {widget/MK}{#1}{##1} }
+      ,MK/#1 .groups:n = annot
      }
  }
 
@@ -959,7 +1025,7 @@
 %    \end{macrocode}
 % Flags.
 %    \begin{macrocode}
-\keys_define:nn { pdffield / annot }
+\keys_define:nn { pdffield  }
   {
     ,setF .code:n =
       {
@@ -968,6 +1034,10 @@
              \bitset_set_true:Nn \l_@@_F_bitset {##1}
            }
       }
+    ,setF .groups:n = annot
+    ,setannotflags .meta:nn =
+      { pdffield }{setF={#1}}
+    ,setannotflags .groups:n = annot
     ,unsetF .code:n =
       {
           \clist_map_inline:nn {#1}
@@ -975,7 +1045,12 @@
              \bitset_set_false:Nn \l_@@_F_bitset {##1}
            }
       }
+    ,unsetF .groups:n = annot
+    ,unsetannotflags .meta:nn =
+      { pdffield }{unsetF={#1}
+    ,unsetannotflags .groups:n = annot
   }
+
 %    \end{macrocode}
 %
 % Keys for the AA dictionary. They all trigger a javascript option.
@@ -985,7 +1060,7 @@
 %    \begin{macrocode}
 \cs_set_protected:Npn \@@_tmpa:n #1  %
   {
-    \keys_define:nn { pdffield / annot }
+    \keys_define:nn { pdffield }
       {
          AA/#1 .code:n =
            {
@@ -1000,12 +1075,51 @@
                   {<</S/JavaScript/JS\l_@@_tmpa_str>>}
                }
            },
+         ,AA/#1 .groups:n = annot
       }
   }
 
 \clist_map_inline:nn {Fo,Bl,D,U,E,X,PO,PC,PV,PI}{\@@_tmpa:n{#1}}
+
+\cs_set_protected:Npn \@@_tmpa:nn #1 #2
+  {
+    \keys_define:nn { pdffield }
+      {
+         #1 .meta:nn =
+           { pdffield }{#2={##1}},
+         #1 .groups:n = {annot}
+      }
+  }
+\@@_tmpa:nn {onfocus}  {Fo}
+\@@_tmpa:nn {onblur}   {Bl}
+\@@_tmpa:nn {onmousedown}{D}
+\@@_tmpa:nn {onmouseup}{U}
+\@@_tmpa:nn {onenter}  {E}
+\@@_tmpa:nn {onexit}   {X}
+%    \end{macrocode}
+% \subsection{Appearances}
+% \begin{macro}{\pdffield_appearance:nn}
+%    \begin{macrocode}
+\cs_new_protected:Npn \pdffield_store_appearance:nn #1 #2
+  {
+     \pdfxform_new:nnn {#1}{}{#2}
+  }
+%for compability ...
+\cs_set_eq:NN \pdffield_store_appearance:nn\pdffield_appearance:nn
 %    \end{macrocode}
+% \subsection{Setup command}
 %
+\keys_define:nn { pdffield / setup }
+  { create-style . code:n = { \@@_style_create:nn #1 } }
+
+\cs_new_protected:Npn \@@_style_create:nn #1#2
+  { \keys_define:nn { pdffield } { #1 .meta:n = {#2} } }
+
+\cs_new_protected:Npn \pdffield_setup:nn #1 #2
+ {
+
+ }
+
 %    \begin{macrocode}
 %</package>
 %    \end{macrocode}





More information about the latex3-commits mailing list.