From a164e409af8e2c2c12db9b23daa2be95397ad89d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 3 Aug 2020 12:21:28 +0900 Subject: popupmenu update --- texmf-dist/doc/latex/popupmenu/README | 19 - texmf-dist/doc/latex/popupmenu/README.md | 18 + .../doc/latex/popupmenu/examples/pu-exmpls.pdf | Bin 0 -> 129503 bytes .../doc/latex/popupmenu/examples/pu-exmpls.tex | 167 +++++ texmf-dist/doc/latex/popupmenu/popupmenu-man.pdf | Bin 0 -> 191000 bytes texmf-dist/doc/latex/popupmenu/popupmenu-man.tex | 685 +++++++++++++++++++++ texmf-dist/doc/latex/popupmenu/popupmenu.pdf | Bin 62982 -> 246473 bytes .../source/latex/popupmenu/examples/pumen_ex.pdf | Bin 33971 -> 0 bytes .../source/latex/popupmenu/examples/pumen_ex.tex | 108 ---- .../latex/popupmenu/examples/pumen_ex_pdftex.tex | 111 ---- texmf-dist/source/latex/popupmenu/popupmenu.dtx | 431 ++++++++++--- texmf-dist/tex/latex/popupmenu/popupmenu.sty | 293 ++++++--- 12 files changed, 1410 insertions(+), 422 deletions(-) delete mode 100644 texmf-dist/doc/latex/popupmenu/README create mode 100644 texmf-dist/doc/latex/popupmenu/README.md create mode 100644 texmf-dist/doc/latex/popupmenu/examples/pu-exmpls.pdf create mode 100644 texmf-dist/doc/latex/popupmenu/examples/pu-exmpls.tex create mode 100644 texmf-dist/doc/latex/popupmenu/popupmenu-man.pdf create mode 100644 texmf-dist/doc/latex/popupmenu/popupmenu-man.tex delete mode 100644 texmf-dist/source/latex/popupmenu/examples/pumen_ex.pdf delete mode 100644 texmf-dist/source/latex/popupmenu/examples/pumen_ex.tex delete mode 100644 texmf-dist/source/latex/popupmenu/examples/pumen_ex_pdftex.tex (limited to 'texmf-dist') diff --git a/texmf-dist/doc/latex/popupmenu/README b/texmf-dist/doc/latex/popupmenu/README deleted file mode 100644 index 16256c50..00000000 --- a/texmf-dist/doc/latex/popupmenu/README +++ /dev/null @@ -1,19 +0,0 @@ -The popupmenu Package - -popupmenu is a LaTeX package used to create a menu structure. This -menu structure (an array of menu items) is passed to the Acrobat -JavaScript method app.popUpMenuEx() method to create a popup menu. -Using the environments defined in this package, and the command -\popUpMenu, you can create and display hierarchical menus. The menu -items can have JavaScript actions associated with them, they can be -marked and dis-enabled. - -The package requires only hyperref. Thus, users of pdftex, dvipdfm, -and dvips can use this package. Two examples are included in the -distribution, additional examples can be found at the AeB Blog - - http://www.math.uakron.edu/~dpstory/aebblog.html - - -D. P. Story -09/27/2010 diff --git a/texmf-dist/doc/latex/popupmenu/README.md b/texmf-dist/doc/latex/popupmenu/README.md new file mode 100644 index 00000000..f60d94df --- /dev/null +++ b/texmf-dist/doc/latex/popupmenu/README.md @@ -0,0 +1,18 @@ +The popupmenu Package +Dated: 2020-07-26 + +popupmenu is a LaTeX package used to create a menu structure. This +menu structure (an array of menu items) is passed to the Acrobat +JavaScript method app.popUpMenuEx() method to create a popup menu. +Using the environments defined in this package, and the command +\popUpMenu, you can create and display hierarchical menus. + +Workflows supported: pdflatex, lualatex, xelatex, +dvips->. + +What's New 2020-07-26: Defined the tracking option and the +\puProcessMenu command to track menu selections. Other +improvements and bug fixes were made. + +D. P. Story +2020-07-29 diff --git a/texmf-dist/doc/latex/popupmenu/examples/pu-exmpls.pdf b/texmf-dist/doc/latex/popupmenu/examples/pu-exmpls.pdf new file mode 100644 index 00000000..cf2c80d0 Binary files /dev/null and b/texmf-dist/doc/latex/popupmenu/examples/pu-exmpls.pdf differ diff --git a/texmf-dist/doc/latex/popupmenu/examples/pu-exmpls.tex b/texmf-dist/doc/latex/popupmenu/examples/pu-exmpls.tex new file mode 100644 index 00000000..ba41a4b9 --- /dev/null +++ b/texmf-dist/doc/latex/popupmenu/examples/pu-exmpls.tex @@ -0,0 +1,167 @@ +\documentclass{article} +%\usepackage{xkeyval} +\usepackage[designv]{web} +\usepackage[tracking]{popupmenu} + +\title{The \texorpdfstring{\textsf}{}{popupmenu} Package Test File} +\author{D. P. Story} +\subject{Test file for the popupmenu Package} +\keywords{LaTeX, popupmenu, Acrobat JavaScript, AcroTeX} + +\university{NORTHWEST FLORIDA STATE COLLEGE\\ + Department of Mathematics} +\email{dpstory@acrotex.net} +\version{1.0} + +\norevisionLabel + +\begin{popupmenu}{Intro} + \item{title=title,return=Title: The manual for the popupmenu package} + \item{title=author,return=Author: D. P. Story} + \item{title=package name,return=Package: popupmenu} +\end{popupmenu} + +\urlPath{\homeAtUA}{http://www.math.uakron.edu/~dpstory} +\urlPath{\homeAeB}{http://www.acrotex.net} +\urlPath{\blogAeB}{http://blog.acrotex.net} +\urlPath{\urlCTAN}{https://www.ctan.org} +\urlPath{\embedYT}{http://www.youtube.com/embed} +\urlPath{\watchYT}{http://www.youtube.com/watch?v} +\begin{popupmenu}{Various} + \item{title=Various AcroTeX Links,return=none} + \item{title=-} + \begin{submenu}{title=AeB at U of Akron} + \item{title=Home page,return=\homeAtUA/acrotex.html} + \item{title=Tutorials,return=\homeAtUA/acrotex.html\#educational} + \end{submenu} + \begin{submenu}{title=Commercial AcroTeX} + \item{title=AcroTeX main page,return=\homeAeB} + \item{title=AcroTeX blog,return=\blogAeB} + \end{submenu} + \begin{submenu}{title=AcroTeX on CTAN} + \item{title=Contributions: AcroTeX ,return=\urlCTAN/author/story} + \item{title=The popupmenu Package,return=\urlCTAN/pkg/popupmenu} + \end{submenu} + \begin{submenu}{title=YouTube Videos} + \begin{submenu}{title=Action Videos} + \item{title=Kung-Fu fighting (Bruce Lee version),return=\embedYT/GZ9e3Dy7obA} + \item{title=Rocket Jump,return=\embedYT/7XzdZ4KcI8Y} + \end{submenu} + \begin{submenu}{title=Miscellaneous} + \item{title=J\"{u}rgen's favorite song,return={\watchYT=mLDF5MBMWHE}} + \item{title=\Esc"Sea Hunt\Esc" US TV series (1958-61) lead-in,return=\embedYT/Lz0aMoWh8Q4} + \item{title=Learn \cs{LaTeX} in one video,return=\embedYT/VhmkLrOjLsw} + \end{submenu} + \end{submenu} +\end{popupmenu} + +\puUseMenus{Intro,Various} % Can track these menus + +%\previewOn + +\def\cs#1{\texttt{\eqbs#1}} +\def\pkg#1{\textsf{#1}} + +\parindent0pt\parskip6pt + +\begin{document} + +\maketitle + +\section{Examples of the documentation} + +Here is a simple example, pass your mouse pointer over the button: +\pushButton[\CA{Info}\BC{}\S{S}\H{N}\AAmouseenter{% + var cChoice = \popUpMenu(Intro);\r + if ( cChoice != null ) app.alert(cChoice); }]{intro}{}{11bp}, uses \cs{popUpMenu}, no tracking. + +Here is the same button \pushButton[\CA{Info}\BC{}\S{S}\H{N}\AAmouseenter{% + var cChoice = \puProcessMenu(Intro);\r + if ( cChoice != null ) app.alert(cChoice); }]{intro}{}{11bp}, but uses \cs{puProcessMenu}, will have tracking. + +For example, make a selection: \pushButton[\CA{My Menu}\AAmouseenter{% +%var cChoice = \popUpMenu(myMenu);\r +var cChoice = \puProcessMenu(Various);\r +if ( cChoice != null ) {\r\t + if (PUdebug)\r\t\t + app.alert("You chose the \\""+cChoice+"\\" menu item");\r\t + else app.launchURL(cChoice);\r +}}]{mymenu}{}{11bp}\olBdry +\pushButton[\TU{Toggle Debug}\CA{Action}\AAmouseup{if(PUdebug){\r\t + PUdebug=false;event.target.buttonSetCaption("Action");} + else {PUdebug=true;event.target.buttonSetCaption("Debug");} +}]{DebugBtn}{.5in}{11bp} (tracking) + +% Declare in the body of the text, can use anywhere after this declaration +\begin{popupmenu}{LocalMenu} + \item {title=First Item} + \item {title=Second Item} +\end{popupmenu} + +Here, in the body, we declare a (simple) menu: \pushButton[\CA{My Menu}\AAmouseenter{% +\LocalMenu\r +var cChoice = \popUpMenu(LocalMenu);\r +if ( cChoice != null ) app.alert("You chose the \\""+cChoice+"\\" menu item"); +}]{LocalMenuBtn}{}{11bp}. This is a locally defined menu, \texttt{popumenu} +declared in the body of the document. (Uses \cs{popUpMenu}, no tracking) + +Pick your choice: +\begin{popupmenu}{puMulti} + \item {title=Item 1,return=0} + \item {title=Item 2,return=1} + \begin{submenu}{title=Other items} + \item{title=Item 3,return=2} + \end{submenu} +\end{popupmenu} +\begin{defineJS}[\makeesc|]{\puMultiActn} +|puMulti +var cChoice = |popUpMenu(puMulti); +if ( cChoice != null ) { + switch (cChoice) { + case "0": + app.alert("You chose Item 1 from the menu"); + break; + case "1": + app.launchURL("|homeAeB"); + break; + default: console.show(); + console.println("Menu returned a value of \\""+cChoice+"\\""); + break; + } +} +\end{defineJS} +\pushButton[\CA{Multi}\AAmouseenter{\puMultiActn}]{MultiBtn}{}{11bp}\olBdry. Locally defined \texttt{popupmenu}, +no tracking. + +\section{Examples using push buttons of \texorpdfstring{\protect\textsf}{}{hyperref}} + +You can use the \cs{PushButton} command of \pkg{hyperref} to accomplish the same thing, but with less flair. +\begin{itemize} + \item Mouse over event: \PushButton[name=hyperbutton1,onenter={% + var cChoice = \puProcessMenu(Various); + if ( cChoice != null )app.launchURL(cChoice);}]{Various URLs} (tracking) + \item Mouse up event: \PushButton[name=hyperbutton2,onclick={% + var cChoice = \puProcessMenu(Various); + if ( cChoice != null )app.launchURL(cChoice);}]{Various URLs} (tracking) +\end{itemize} + +\section{Handling the `none' return value} + +The handling of a return value of `none' is automatic when \cs{puProcessMenu} is used. When +\cs{popUpMenu} is employed, some special attention is needed. The topmost item of the +menu \texttt{Various} has a return value of `none'. +\begin{itemize} + \item With tracking: \pushButton[\CA{My Menu}\AAmouseenter{% + var cChoice = \puProcessMenu(Various);\r + if ( cChoice != null ) app.launchURL(cChoice); + }]{mymenu}{}{11bp} + \item Without tracking: \pushButton[\CA{My Menu}\AAmouseenter{% + % \popUpMenu returns the string "null", so we must test if "null" is the return value, + % if so, we make cChoice=null + var cChoice = \popUpMenu(Various);\r + if (cChoice=="null") cChoice=null;\r + if ( cChoice != null ) app.launchURL(cChoice); + }]{mymenu}{}{11bp} +\end{itemize} + +\end{document} \ No newline at end of file diff --git a/texmf-dist/doc/latex/popupmenu/popupmenu-man.pdf b/texmf-dist/doc/latex/popupmenu/popupmenu-man.pdf new file mode 100644 index 00000000..b498159c Binary files /dev/null and b/texmf-dist/doc/latex/popupmenu/popupmenu-man.pdf differ diff --git a/texmf-dist/doc/latex/popupmenu/popupmenu-man.tex b/texmf-dist/doc/latex/popupmenu/popupmenu-man.tex new file mode 100644 index 00000000..150fc84c --- /dev/null +++ b/texmf-dist/doc/latex/popupmenu/popupmenu-man.tex @@ -0,0 +1,685 @@ +\documentclass{article} +\usepackage[fleqn]{amsmath} +\usepackage[ + web={centertitlepage,designv,tight*,usetemplates, + forcolorpaper,latextoc,pro},%usesf, + eforms,aebxmp +]{aeb_pro} +%\usepackage{multicol} +%\usepackage{aeb_mlink} +\usepackage[tracking]{popupmenu} +\usepackage{array} +\usepackage[altbullet]{lucidbry} + +%\previewOn + +\usepackage{makeidx} +\makeindex +\usepackage{acroman} + +\leftmargini\parindent + + +\usepackage[active]{srcltx} + +\urlstyle{rm} +\let\tops\texorpdfstring +\let\pkg\textsf +\let\app\textsf +\let\opt\texttt +\let\uif\textsf +\let\env\texttt +\def\meta#1{\textit{\texttt{#1}}} +\def\ameta#1{$\langle\textit{\texttt{#1}}\rangle$} +\newdimen\aebdimen \aebdimen6pt %\partopsep \advance\aebdimen\partopsep +\newcommand\bVerb[1][]{\begingroup#1\vskip\aebdimen\parindent0pt}% +\def\eVerb{\vskip\aebdimen\endgroup\noindent} +\def\SUB#1{\ensuremath{{}_{\text{#1}}}} +\def\darg#1{\texttt{\{#1\}}} +\def\takeMeasure{\bgroup\obeyspaces\takeMeasurei} +\def\takeMeasurei#1{\global\setbox\webtempboxi\hbox{\ttfamily#1}\egroup} +\def\bxSize{\wd\webtempboxi+2\fboxsep+2\fboxrule} +\let\amtIndent\leftmargini +\makeatletter +\def\setDisplayNumber#1#2{\kern0pt + \setlength\abovedisplayshortskip{0pt}% + \setlength\belowdisplayshortskip{0pt}% + \setlength\abovedisplayskip{0pt}% + \setlength\belowdisplayskip{0pt}% + \begin{equation}\label{#2}\end{equation}\kern0pt +} +\renewenvironment{quote}[1][] + {\def\@rgi{#1}\ifx\@rgi\@empty + \let\rghtm\@empty\else\def\rghtm{\rightmargin\leftmargin}\fi + \list{}{\rghtm} %{\rightmargin\leftmargin}% + \item\relax} + {\endlist} +\renewcommand*\descriptionlabel[1]{\hspace\labelsep + \normalfont #1} +\setcounter{secnumdepth}{4} +\setcounter{tocdepth}{5} +\renewcommand*{\theparagraph}{\texorpdfstring{\protect\P\protect\ }{\textparagraph}} +\renewcommand{\paragraph} + {\renewcommand{\@seccntformat}[1]{\theparagraph}% + \@startsection{paragraph}{4}{0pt}{6pt}{-3pt}{\bfseries}} %\color{\aeb@subsubsectioncolor} +\renewcommand*\l@paragraph{\@dottedtocline{4}{5.0em}{1em}} %{7.0em}{4.1em}} +\def\chgCurrLblName#1{\def\@currentlabelname{#1}} +\def\echgCurrLblName#1{\edef\@currentlabelname{#1}} +\makeatother + +\reversemarginpar +\def\FmtMP#1{\marginpar{\slshape\raggedleft\small#1}} + + +\newcommand{\YT}{\textsf{YouTube}} + + +%\def\tutpath{doc/tutorial} +%\def\tutpathi{tutorial} + +\DeclareDocInfo +{ + university={\AcroTeX.Net}, + title={The manual for the \tops{\protect\pkg}{}{popupmenu} package}, +% title={The \texorpdfstring{\textsf{popupmenu} Package\\[1em]}{: } +% Create popup-menus to perform actions}, + author={D. P. Story}, + email={dpstory@acrotex.net}, + subject={Creating popup-menues}, + talksite={\url{www.acrotex.net}}, + version={1.2, 2020/07/26}, + keywords={AcroTeX, PDF, popup-menus, JavaScript}, + copyrightStatus=True, + copyrightNotice={Copyright (C) \the\year, D. P. Story}, + copyrightInfoURL={http://www.acrotex.net} +} + +\def\dps{$\hbox{$\mathfrak D$\kern-.3em\hbox{$\mathfrak P$}% + \kern-.6em \hbox{$\mathcal S$}}$} + +\universityLayout{fontsize=Large} +\titleLayout{fontsize=LARGE} +\authorLayout{fontsize=Large} +\tocLayout{fontsize=Large,color=aeb} +\sectionLayout{indent=-40pt,fontsize=large,color=aeb} %,afterskip=1sp} +\subsectionLayout{indent=-20pt,color=aeb} %,afterskip=1sp} +\subsubsectionLayout{indent=0pt,color=aeb} %,afterskip=1sp} +\subsubDefaultDing{\texorpdfstring{$\bullet$}{\textrm\textbullet}} + +\def\thispkg{\pkg{popupmenu}} + +\let\tops\texorpdfstring +\newenvironment{eqComments}[1][\strut]{\smallskip\leftskip-\labelwidth +\item[]\textbf{\textcolor{blue}{#1}}}{\par\smallskip} + +\begin{popupmenu}{Intro} + \item{title=title,return=Title: The manual for the popupmenu package} + \item{title=author,return=Author: D. P. Story} + \item{title=package name,return=Package: popupmenu} +\end{popupmenu} + +\urlPath{\homeAtUA}{http://www.math.uakron.edu/~dpstory} +\urlPath{\homeAeB}{http://www.acrotex.net} +\urlPath{\blogAeB}{http://blog.acrotex.net} +\urlPath{\urlCTAN}{https://www.ctan.org} +\urlPath{\embedYT}{http://www.youtube.com/embed} +\urlPath{\watchYT}{http://www.youtube.com/watch?v} +\begin{popupmenu}{Various} + \item{title=Various AcroTeX Links,return=none} + \item{title=-} + \begin{submenu}{title=AeB at U of Akron} + \item{title=Home page,return=\homeAtUA/acrotex.html} + \item{title=Tutorials,return=\homeAtUA/acrotex.html\#educational} + \end{submenu} + \begin{submenu}{title=Commercial AcroTeX} + \item{title=AcroTeX main page,return=\homeAeB} + \item{title=AcroTeX blog,return=\blogAeB} + \end{submenu} + \begin{submenu}{title=AcroTeX on CTAN} + \item{title=Contributions: AcroTeX ,return=\urlCTAN/author/story} + \item{title=The popupmenu Package,return=\urlCTAN/pkg/popupmenu} + \end{submenu} + \begin{submenu}{title=YouTube Videos} + \begin{submenu}{title=Action Videos} + \item{title=Kung-Fu fighting (Bruce Lee version),return=\embedYT/GZ9e3Dy7obA} + \item{title=Rocket Jump,return=\embedYT/7XzdZ4KcI8Y} + \end{submenu} + \begin{submenu}{title=Miscellaneous} + \item{title=J\"{u}rgen's favorite song,return={\watchYT=mLDF5MBMWHE}} + \item{title=\Esc"Sea Hunt\Esc" US TV series (1958-61) lead-in,return=\embedYT/Lz0aMoWh8Q4} + \item{title=Learn \cs{LaTeX} in one video,return=\embedYT/VhmkLrOjLsw} + \end{submenu} + \end{submenu} +\end{popupmenu} + +\puUseMenus{Intro,Various} + +\chngDocObjectTo{\newDO}{doc} +\begin{docassembly} +var titleOfManual="The popupmenu MANUAL"; +var manualfilename="Manual_BG_Print_popupmenu.pdf"; +var manualtemplate="Manual_BG_Brown.pdf"; // Blue, Green, Brown +var _pathToBlank="C:/Users/Public/Documents/ManualBGs/"+manualtemplate; +var doc; +var buildIt=false; +if ( buildIt ) { + console.println("Creating new " + manualfilename + " file."); + doc = \appopenDoc({cPath: _pathToBlank, bHidden: true}); + var _path=this.path; + var pos=_path.lastIndexOf("/"); + _path=_path.substring(0,pos)+"/"+manualfilename; + \docSaveAs\newDO ({ cPath: _path }); + doc.closeDoc(); + doc = \appopenDoc({cPath: manualfilename, oDoc:this, bHidden: true}); + f=doc.getField("ManualTitle"); + f.value=titleOfManual; + doc.flattenPages(); + \docSaveAs\newDO({ cPath: manualfilename }); + doc.closeDoc(); +} else { + console.println("Using the current "+manualfilename+" file."); +} +var _path=this.path; +var pos=_path.lastIndexOf("/"); +_path=_path.substring(0,pos)+"/"+manualfilename; +\addWatermarkFromFile({ + bOnTop:false, + bOnPrint:false, + cDIPath:_path +}); +\executeSave(); + +\end{docassembly} + +\begin{document} + +\maketitle + +\selectColors{linkColor=black} +\tableofcontents +\selectColors{linkColor=webgreen} + +\section{Introduction}\label{s:intro} + +Acrobat JavaScript has an interesting function, \texttt{app.popUpMenuEx()}, +that we exploit in this package. The function takes as its argument an array +of structured menu items and displays these items as a pop-up menu. When an +item is selected, a value is returned, which can then be acted upon in some +way. Here is a simple example, pass your mouse pointer over the button: +\pushButton[\CA{Info}\BC{}\S{S}\H{N}\AAmouseenter{% + var cChoice = \popUpMenu(Intro);\r + if ( cChoice != null ) app.alert(cChoice); }]{intro}{}{11bp}\olBdry. This +documentation describes the environments, commands, and JavaScript required +to create such pop-up menus. + +\subsection{Sample files} + +The file \texttt{pu-exmpls.tex} is the only demo file; it incorporates the examples of this +documentation, as well as few other bits and pieces. + +\subsection{Options, requirements, and workflows} + +\paragraph*{Options.} There are two options for this package +\opt{tracking}\FmtMP{\opt{tracking}} and \opt{!tracking} (the default). The +push button \pushButton[\CA{Info}\BC{}\S{S}\H{N}\AAmouseenter{var cChoice = + \popUpMenu(Intro);\r if ( cChoice != null ) app.alert(cChoice); + }]{intro}{}{11bp} introduced earlier is an example of a menu system with + \emph{no tracking} (\opt{!tracking}). As you selected menu items appearance + of the item does not change. When the \opt{tracking} option is taken, the + menu keeps track of which menu item is selected by placing a check mark to + the left of the menu item; for example, + \pushButton[\CA{Info}\BC{}\S{S}\H{N}\AAmouseenter{trackingPU=true;\r var + cChoice = \puProcessMenu(Intro);\r if ( cChoice != null ) + app.alert(cChoice); }]{intro}{}{11bp}\olBdry, notice as you select items, a + check mark appears; select another item, the previous check mark is removed, + and the latest item selected is now checked. More on tracking in \hyperref[s:tracking]{Section~\ref*{s:tracking}}. + +\paragraph*{Requirements.} +This package requires the \pkg{eforms} package, which is part of \pkg{acrotex}.\footnote{\url{http://www.ctan/pkg/acrotex}} + +\paragraph*{Workflows.} This is a general {\LaTeX} package, any workflows can be used to build +a \thispkg{} document: \app{pdflatex}, \app{lualatex}, \app{xelatex}, or +\app{dvips\,->\,\ameta{\upshape{distiller\,\string|\,ps2pdf}}}.\footnote{\pkg{popupmenu} +uses document JavaScript when \cs{puUseMenus} is expanded in the preamble; +\app{ps2pdf} does not support the creation of document JavaScript. If all +menu structures are defined as field scripts, \app{ps2pdf} should work. See +Section~\ref*{ps2pdf} for more information.} + +\section{The \tops{\protect\pkg}{}{popupmenu} environment} + +%\typeout{!! \Intro } + +To generate a pop-up menu using \texttt{app.popUpMenuEx()} you need to pass to it through its argument +a menu-array. The most convenient way of creating this ``menu-array'' is with the \env{popupmenu} environment. Before +discussing the full syntax of \env{popupmenu} we reproduce the \env{popupmenu} environment that produced the \textsf{Intro} +button in first paragraph of this section: +\begin{Verbatim}[fontsize=\small,commandchars=!()] +\begin{popupmenu}{Intro} + \item{title=title,return=Title: The manual for the popupmenu package} + \item{title=author,return=Author: D. P. Story} + \item{title=package name,return=Package: popupmenu} +\end{popupmenu} +\end{Verbatim} +This environment defines a JavaScript variable \texttt{Intro} and a {\LaTeX} command \cs{Intro} +that expands to what you see below. +\begin{Verbatim}[fontsize=\small,commandchars=!()] +var Intro = [ + {cName: "title", cReturn: "Title: The manual for the popupmenu package"}, + {cName: "author", cReturn: "Author: D. P. Story"}, + {cName: "package name", cReturn: "Package: popupmenu"} +]; +\end{Verbatim} +The above is a properly formed ``menu-array''. + +\newtopic\noindent +The rollover push button was created with the following code: +\begin{Verbatim}[fontsize=\small,commandchars={|~@}] +\pushButton[\CA{Info}\BC{}\S{S}\H{N}\AAmouseenter{% + var cChoice = \popUpMenu(Intro);\r + if ( cChoice != null ) app.alert(cChoice); }]{intro}{}{11bp} +\end{Verbatim} +The mouse-enter JavaScript is \texttt{var\:cChoice\:=\:\string\popUpMenu(Intro)}. The +array name (\texttt{Intro}) is passed to the convenience command +\cs{popUpMenU} to get the return value \texttt{cChoice}.\footnote{The name of the return variable is your choice, +you can say \texttt{var retn=\cs{popUpMenu(Intro)}}, for example.} Finally, if +nonempty, an alert dialog box is emitted with the return value displayed in +it. BTY,\footnote{By the way} \cs{popUpMenu} expands to the JavaScript method +\texttt{app.popUpMenuEx()}. + +\section{The \tops{\env}{}{popupmenu} environment} + +This general syntax for the \env{popupmenu} environment is, +\bVerb\takeMeasure{\small\string\item\darg{title=\ameta{str},marked=\ameta{\upshape{true|false}},enabled=\ameta{\upshape{true|false}},return=\ameta{str}}}% +\setlength\eflength{\bxSize}% +\def\1{\rlap{\hskip\eflength\ding{182}}} +\def\2{\rlap{\hskip\eflength\ding{183}}} +\def\3{\rlap{\hskip\eflength\ding{184}}} +\def\4{\rlap{\hskip\eflength\ding{185}}} +\begin{minipage}{\linewidth} +\begin{minipage}{\bxSize} +\xdef\panelWidth{\the\linewidth}% *[\ameta{opts}]\darg{\ameta{ytvID}}\darg{\ameta{text}} +\begin{Verbatim}[frame=single,commandchars=!(),rulecolor=\color{red},fontsize=\small] +!1\begin{popupmenu}{!ameta(name)} +!2\item{title=!ameta(str),marked=!ameta(!upshape(true|false)),enabled=!ameta(!upshape(true|false)),return=!ameta(str)} +!3\item{title=-} +... +!4\begin{submenu}{title=!ameta(str),marked=!ameta(!upshape(true|false))} +\item{title=!ameta(str),marked=!ameta(!upshape(true|false)),enabled=!ameta(!upshape(true|false)),return=!ameta(str)} +\item{title=-} +... +\end{submenu} +... +\end{popupmenu} +\end{Verbatim} +\end{minipage}\hfill +\begin{minipage}{\linewidth-\panelWidth} +\setDisplayNumber\label{display:puenv} +\end{minipage}\end{minipage}\eVerb +At the top-level \ding{182}, the \env{popupmenu} environment takes one +argument. The \ameta{name} argument plays two roles: (1) it becomes the name +of the JavaScript \emph{menu-array}; (2) it becomes a command name +\cs{\ameta{name}} that expands to the JavaScript menu-array. For this reason, +\ameta{name} must consist of ASCII letters only. The body of \env{popupmenu} +consists of one or more \cs{item} commands (\ding{183} and \ding{184}). The +body may contain zero or more \env{submenu} environments (\ding{185}); +\env{submenu} may then contain one or more \cs{item} commands. You can have +sub-menus inside other sub-menus. + +Generally, some underlying JavaScript, such as when the \opt{tracing} option +is in force, sets a menu item to \texttt{marked=true} or +\texttt{marked=false}; so as a rule, it is not recommended to initially specify +the \texttt{marked} key. + +\paragraph*{Discussion of \cs{item\darg{\ameta{KV-pairs}}}.} There are four key-value pairs. +\begin{quote} +\begin{description} + \item[\texttt{title=\ameta{str\upshape{\string|-}}}] (required) The + value of \texttt{title} (\ameta{str}) is the menu item title; a + value of `\texttt{-}' is reserved to signal that a separator line + should be drawn. + \item[\texttt{marked=\ameta{\upshape{true\string|false}}}] (optional) + If \texttt{true}, the menu item is marked with a check. The default + is \texttt{false} (not marked). Leave this key to JavaScript. + \item[\texttt{enabled=\ameta{\upshape{true\string|false}}}] (optional) + If \texttt{true} the item is to appear enabled; otherwise the menu + item is grayed out. The default is \texttt{true} (enabled). + \item[\texttt{return=\ameta{str}}] (optional) A string to be returned + when the menu item is selected. If \texttt{return} is not specified + or has no value, the value of the \texttt{title} key is returned. + There is a special return value; if \ameta{str} is the word + `\texttt{none}', the return value will be \texttt{null} (no + action). In this case, the value of the \texttt{title} key can be + used as a heading. (There is an example of the `\texttt{none}' value + in Section~\ref*{Exepu}.) +\end{description} +\end{quote} + +\paragraph*{Discussion of \env{submenu\darg{\ameta{KV-pairs}}}.} The argument of \env{submenu} +takes only two key-value pairs: \texttt{title} and \texttt{marked}, see descriptions above. + +\paragraph*{Placement of the \env{popupmenu} environment.} The environment may appear in the +preamble or in the body of the document. +\begin{itemize} + \item\textbf{In the preamble.} When one or more \env{popupmenu} + environments are declared in the preamble, their corresponding + menu-array can be placed as document JavaScript. To place one or + more menu-arrays in the document JavaScript section of the PDF, + insert the \cs{puUseMenus} command following the last + \env{popupmenu} environment in the preamble. +\bVerb\takeMeasure{\string\puUseMenus\darg{\ameta{menu-array-names}}}\par\noindent +\begin{minipage}{\linewidth} +\begin{minipage}{\bxSize} +\xdef\panelWidth{\the\linewidth}% +\begin{Verbatim}[frame=single,commandchars=!(),rulecolor=\color{red}] +\puUseMenus{!ameta(menu-array-names)} +\end{Verbatim} +\end{minipage}\hfill +\begin{minipage}{\linewidth-\panelWidth} +\setDisplayNumber\label{display:puUseMenus} +\end{minipage}\end{minipage}\eVerb +where \ameta{menu-array-names} is a comma-delimited list of +menu-array names; for example, \cs{puUseMenus\darg{myMenu,yourMenu}}. + +Tracing can only occur when (1) the \env{popupmenu} environment appears in +the preamble; (2) and the \ameta{name} of the pop-up menu appears as one of +the arguments of \cs{puUseMenus}; and (3) the command \cs{puProcessMenu} is +used at the field level to open the pop-up, more on this in \hyperref[s:tracking]{Section~\ref*{s:tracking}}. + +\item\textbf{In the body of the document.} For \env{popupmenus} + environments declared in the body of the document, the corresponding + menu-arrays can still be used anywhere after the declaration. Refer to + \hyperref[s:notracking]{Section~\ref*{s:notracking}} for details. +\end{itemize} + +\section{Executing a pop-up menu}\label{Exepu} + +Two commands used to open a pop-up menu, \cs{popUpMenu} and \cs{puProcessMenu}: +\bVerb\takeMeasure{\string\puProcessMenu\darg{\ameta{name}}}% +\setlength\eflength{\bxSize}\def\1{\sffamily\rlap{\hskip\eflength(for no-tracking menus)}}% +\def\2{\sffamily\rlap{\hskip\eflength(for tracking menus)}}\par\noindent +\begin{minipage}{\linewidth} +\begin{minipage}{\bxSize} +\xdef\panelWidth{\the\linewidth}% +\begin{Verbatim}[frame=single,commandchars={!~@},rulecolor=\color{red}] +!1\popUpMenu(!ameta~name@) +!2\puProcessMenu(!ameta~name@) +\end{Verbatim} +\end{minipage}\hfill +\begin{minipage}{\linewidth-\panelWidth} +\setDisplayNumber\label{display:puCMDS} +\end{minipage}\end{minipage}\eVerb where \ameta{name} is the name given to some +\env{popupmenu} environment, refer to +\hyperref[display:puenv]{display~(\ref*{display:puenv})}, defined earlier in +the document. The first one is designed for no-tracking menus, the second is +for tracking menus. + +\paragraph*{The \texttt{Various} menu.}\label{para:Various} +In subsequent sections, we'll use the following pop-up menu, which is defined +in the preamble of this document. +\begin{Verbatim}[fontsize=\small,numbers=left] +\urlPath{\homeAtUA}{http://www.math.uakron.edu/~dpstory} +\urlPath{\homeAeB}{http://www.acrotex.net} +\urlPath{\blogAeB}{http://blog.acrotex.net} +\urlPath{\urlCTAN}{https://www.ctan.org} +\urlPath{\embedYT}{http://www.youtube.com/embed} +\urlPath{\watchYT}{http://www.youtube.com/watch?v} +\begin{popupmenu}{Various} + \item{title=Various AcroTeX Links,return=none} % return value of 'none' + \item{title=-} + \begin{submenu}{title=AeB at U of Akron} + \item{title=Home page,return=\homeAtUA/acrotex.html} + \item{title=Tutorials,return=\homeAtUA/acrotex.html\#educational} + \end{submenu} + \begin{submenu}{title=Commercial AcroTeX} + \item{title=AcroTeX main page,return=\homeAeB} + \item{title=AcroTeX blog,return=\blogAeB} + \end{submenu} + \begin{submenu}{title=AcroTeX on CTAN} + \item{title=Contributions: AcroTeX, + return=\urlCTAN/author/story} + \item{title=The popupmenu Package, + return=\urlCTAN/pkg/popupmenu} + \end{submenu} + \begin{submenu}{title=YouTube Videos} + \begin{submenu}{title=Action Videos} + \item{title=Kung-Fu fighting (Bruce Lee version), + return=\embedYT/GZ9e3Dy7obA} + \item{title=Rocket Jump,return=\embedYT/7XzdZ4KcI8Y} + \end{submenu} + \begin{submenu}{title=Miscellaneous} + \item{title=J\"{u}rgen's favorite song, + return={\watchYT=mLDF5MBMWHE}} + \item{title=\Esc"Sea Hunt\Esc" US TV series (1958-61) lead-in, + return=\embedYT/Lz0aMoWh8Q4} + \item{title=Learn \cs{LaTeX} in one video, + return=\embedYT/VhmkLrOjLsw} + \end{submenu} + \end{submenu} +\end{popupmenu} +\end{Verbatim} +\textbf{Notes:} +\begin{itemize} +\item In lines~(1)--(6), several URLs are declared using + \cs{urlPath}\FmtMP{\cs{urlPath}}, which is defined in \pkg{popupmenu} + package. +\item Line~(8) The `\texttt{none}; return value is used. +\item Line~(12) The fragment (\texttt{\#}) is escaped (\verb~\#~). +\item Line~(31) The value of the \texttt{title} key is passed through the + \pkg{hyperref} command \cs{pdfstringdef}, consequently, you can use + standard {\LaTeX} markup for Latin-1 characters. +\item Line~(32) The return value has an equal sign (\texttt{=}), the return value + is enclosed in braces to avoid a \pkg{xkeyval} parsing error. +\item Line~(33) The double quote needs to be escaped (because ultimately, + the value will appear within double quotes. We use a special + \cs{Esc}\FmtMP{\cs{Esc}} command of \pkg{popupmenu}. +\item Line~(35) To place a backslash(`\texttt\eqbs'), use the \cs{cs}\FmtMP{\cs{cs}} command. +\end{itemize} + +\newtopic\noindent +The \env{popupmenu} can be placed in the preamble or in the body of the document. Let's begin with the +one declared in the body. + +\subsection{Declaring \tops{\protect\env}{}{popupmenu} in the body}\label{s:notracking} + +%\previewOn + +\begin{popupmenu}{LocalMenu} + \item {title=First Item} + \item {title=Second Item} +\end{popupmenu} + +Here, in the body, we declare a (simple) menu: \pushButton[\CA{My Menu}\AAmouseenter{% +\LocalMenu\r +var cChoice = \popUpMenu(LocalMenu);\r +if ( cChoice != null ) app.alert("You chose the \\""+cChoice+"\\""); +}]{LocalMenuBtn}{}{11bp}\begingroup +\def\1{\llap{\rlap{\ding{182}}\hskip\amtIndent\relax}}% +\def\2{\llap{\rlap{\ding{183}}\hskip\amtIndent\relax}}% +\def\3{\llap{\rlap{\ding{184}}\hskip\amtIndent\relax}}% +\begin{Verbatim}[xleftmargin=\amtIndent,fontsize=\small,commandchars={|~@}] +|1\begin{popupmenu}{LocalMenu} + \item {title=First Item} + \item {title=Second Item} +\end{popupmenu} +\pushButton[\CA{My Menu}\AAmouseenter{% +|2\LocalMenu\r //|sffamily Expand the command version of the menu-array +|3var cChoice = \popUpMenu(LocalMenu);\r //|sffamily use \popUpMenu +if ( cChoice != null ) + app.alert("You chose the \\""+cChoice+"\\""); +}]{LocalMenuBtn}{}{11bp} +\end{Verbatim} +\endgroup\noindent +In line~\ding{182} we decare our simple menu. In line~\ding{183} we expand +the command version of the \emph{menu-array}. (Refer to comment \ding{182} of +\hyperref[display:puenv]{display~(\ref*{display:puenv})} on +page~\pageref*{display:puenv}.) Finally, in line~\ding{184}, we execute +\cs{popUpMenu(LocalMenu)} (See +\hyperref[display:puCMDS]{display~(\ref*{display:puCMDS})} on +page~\pageref*{display:puCMDS}, and the comments that follow). Using this +technique, there is \emph{no tracking}; that is, the menu item chosen is not +checked. + +The \env{popupmenu} can be declared in the preamble to obtain the same +results, but still no tracking. To obtain tracking of the menu items, you +must (1) declare \env{popupmenu} in the preamble; (2) include its name +(\texttt{LocalMenu}) in the list of \ameta{menu-array-names} of the +\cs{puUseMenus} command of +\hyperref[display:puUseMenus]{display~(\ref*{display:puUseMenus})}; (3) +delete line~\ding{183}; (4) replace \cs{popUpMenu} in line~\ding{184} with +\cs{puProcessMenu}; and (5) the \opt{tracking} option must be specified. +Details of setting up tracking are found in the +\hyperref[{s:tracking}]{Section~\ref*{s:tracking}}. + +\subsection{Declaring \tops{\protect\env}{}{popupmenu} in the preamble}\label{s:tracking} + +A \env{popupmenu} environment can be declared anywhere \emph{before} its first use in +field Java\-Script to actually display the menu to the user; however, to obtain +tracking of the menu items chosen you must (1) specify +\cs{usepackage[tracking]\darg{popupmenu}}, the \opt{tracking} option; (2) +declare the menu (that is, the \env{popupmenu} environment) in the preamble; (3) list the menu name +amongst the arguments of the \cs{puUseMenus} command; (4) use +\cs{puProcessMenu} in lieu of \cs{popUpMenu} in the field JavaScript. + +\newtopic\noindent A bare-bones push button is as follows: +\begin{Verbatim}[xleftmargin=\amtIndent,fontsize=\small,commandchars={|~@}] +\pushButton[|ameta~KV-pairs@\AAmouseenter{% + var cChoice = \puProcessMenu(|ameta~name@);\r + if ( cChoice != null ) |ameta~some-action@ +}}]{|ameta~btnName@}{|ameta~wd@}{|ameta~ht@} +\end{Verbatim} + + +\newtopic\noindent +For example, make a selection: \pushButton[\CA{My Menu}\BC{}\W0\S{S}\H{N}\AAmouseenter{% +var cChoice = \puProcessMenu(Various);\r +if ( cChoice != null ) {\r\t + if (PUdebug)\r\t\t + app.alert("URL: \\""+cChoice+"\\"");\r\t + else app.launchURL(cChoice);\r +}}]{mymenu}{}{11bp}\olBdry\, +\pushButton[\TU{Toggle Debug}\BC{}\W0\S{S}\H{N}\CA{Action}\AAmouseup{if(PUdebug){\r\t + PUdebug=false;event.target.buttonSetCaption("Action");}\r + else {PUdebug=true;event.target.buttonSetCaption("Debug");} +}]{DebugBtn}{.5in}{11bp} + +\newtopic\noindent The verbatim listing of the first push button follows: +\begin{Verbatim}[xleftmargin=\amtIndent,fontsize=\small,commandchars={|~@}] +\pushButton[\CA{My Menu}\BC{}\W0\S{S}\H{N}\AAmouseenter{% +var cChoice = \puProcessMenu(Various);\r +if ( cChoice != null ) {\r\t + if (PUdebug)\r\t\t + app.alert("URL: \\""+cChoice+"\\"");\r\t + else app.launchURL(cChoice);\r +}}]{mymenu}{}{11bp} +\end{Verbatim} +This push button references the \texttt{Various} menu, tediously listed on +page~\pageref*{para:Various}. The second button, labeled \textsf{Action}, +allows you to play around with the pop-up menu without going to the web +sites. Click on it, and the caption now says \textsf{Debug}. Now, instead of +going to the web site, an alert box appears announcing your choice. Good for +testing things. + +\paragraph*{Multiple action types.} In all the examples of this document, as well as the demo files, +all actions are the same, either the return is a URL and the action is +\texttt{app.launchURL(URL)} or the return is text and results are reported in +an alert box. You can have multiple action types, as is illustrated in the +following local declaration. + +%\previewOff + +\newtopic\noindent Pick your choice: +\begin{popupmenu}{puMulti} + \item {title=Item 1,return=0} + \item {title=Item 2,return=1} + \begin{submenu}{title=Other items} + \item{title=Item 3,return=2} + \end{submenu} +\end{popupmenu} +\begin{defineJS}[\makeesc|]{\puMultiActn} +|puMulti +var cChoice = |popUpMenu(puMulti); +if ( cChoice != null ) { + switch (cChoice) { + case "0": + app.alert("You chose Item 1 from the menu"); + break; + case "1": + app.launchURL("|homeAeB"); + break; + default: + console.show() + console.println("Menu returned a value of \\""+cChoice+"\\""); + break; + } +} +\end{defineJS} +\pushButton[\CA{Multi}\AAmouseenter{\puMultiActn}]{MultiBtn}{}{11bp}\olBdry. +The verbatim list is, +\begin{Verbatim}[xleftmargin=\amtIndent,fontsize=\small,commandchars={*~@}] +%*textsf~ Use the *texttt~defineJS@ environment to define the action@ +\begin{defineJS}[\makeesc|]{\puMultiActn} +|puMulti +var cChoice = |popUpMenu(puMulti); +if ( cChoice != null ) { + switch (cChoice) { + case "0": + app.alert("You chose Item 1 from the menu");break; + case "1": + app.launchURL("|homeAeB");break; + default: console.show(); + console.println("Menu returned a value of \\""+cChoice+"\\""); + break; + } +} +\end{defineJS} +*goodbreak +%*textsf~ Declare *texttt~popupmenu@ environment, return values are integers@ +\begin{popupmenu}{puMulti} + \item {title=Item 1,return=0} + \item {title=Item 2,return=1} + \begin{submenu}{title=Other items} + \item{title=Item 3,return=2} + \end{submenu} +\end{popupmenu} +%*textsf~ Now execute the pop-up menu as a mouse enter event@ +\pushButton[\CA{Multi}\AAmouseenter{\puMultiActn}]{MultiBtn}{}{11bp} +\end{Verbatim} + +\section{Remarks on \tops{\protect\app}{}{ps2pdf}}\label{ps2pdf} + +To use the \app{dvips\,->\,ps2pdf} workflow, document JavaScript needs to be avoided. +Do not use the \opt{tracking} option, do not use \cs{puUseMenus}, and use only the +\cs{popUpMenu} command in field JavaScript. A simple outline of an document is found below, +it is a working example. +\begin{Verbatim}[fontsize=\small,commandchars={*~@}] +\documentclass{article} +\usepackage{popupmenu} +\parindent0pt\parskip6pt +\begin{document} +%*textsf~ Declare in the body of the text, can use anywhere after this declaration@ +\begin{popupmenu}{LocalMenu} + \item {title=First Item} + \item {title=Second Item} +\end{popupmenu} + +Pop-up menu using \verb|\pushButton| of \textsf{eforms}: +\pushButton[\CA{My Menu}\AAmouseenter{\LocalMenu\r +var cChoice = \popUpMenu(LocalMenu);\r +if ( cChoice != null )\r\t + app.alert("You chose the \\""+cChoice+"\\" menu item"); +}]{LocalMenuBtn}{}{11bp}. + +Pop-up menu using \verb|\PushButton| of \textsf{hyperref}: +\PushButton[name=hyperbutton1,onenter={\LocalMenu + var cChoice = \popUpMenu(LocalMenu); + if ( cChoice != null ) + app.alert("You chose the \\""+cChoice+"\\" menu item");} +]{My Menu} +\end{document} +\end{Verbatim} + + +\paragraph*{Back to my retirement.} \dps + + +\end{document} diff --git a/texmf-dist/doc/latex/popupmenu/popupmenu.pdf b/texmf-dist/doc/latex/popupmenu/popupmenu.pdf index daf3bbea..6c1e54b1 100644 Binary files a/texmf-dist/doc/latex/popupmenu/popupmenu.pdf and b/texmf-dist/doc/latex/popupmenu/popupmenu.pdf differ diff --git a/texmf-dist/source/latex/popupmenu/examples/pumen_ex.pdf b/texmf-dist/source/latex/popupmenu/examples/pumen_ex.pdf deleted file mode 100644 index c576f284..00000000 Binary files a/texmf-dist/source/latex/popupmenu/examples/pumen_ex.pdf and /dev/null differ diff --git a/texmf-dist/source/latex/popupmenu/examples/pumen_ex.tex b/texmf-dist/source/latex/popupmenu/examples/pumen_ex.tex deleted file mode 100644 index 6f0acc7a..00000000 --- a/texmf-dist/source/latex/popupmenu/examples/pumen_ex.tex +++ /dev/null @@ -1,108 +0,0 @@ -\documentclass{article} -\usepackage[designv]{web} -\usepackage{eforms} -\usepackage{popupmenu} - -\title{The \texorpdfstring{\textsf{popupmenu}}{popupmenu} Package Test File} -\author{D. P. Story} -\subject{Test file for the popupmenu Package} -\keywords{LaTeX, popupmenu, Acrobat JavaScript, AcroTeX} - -\university{NORTHWEST FLORIDA STATE COLLEGE\\ - Department of Mathematics} -\email{dpstory@acrotex.net} -\version{1.0} - -%\nocopyright -\norevisionLabel - -% -% This package can be used by users of pdftex, dvipdfm, dvips (with distiller) -% - -\urlPath{\aebhome}{http://www.math.uakron.edu/~dpstory} - -\begin{popupmenu}{AeBMenu} - \item{title=AeB, return=\aebhome/webeq.html} - \item{title=-} - \begin{submenu}{title=AeB Pro Family} - \item{title=Home page,return=\aebhome/aeb_pro.html} - \item{title=Graphicxsp,return=\aebhome/graphicxsp.html} - \end{submenu} - \item{title=eqExam,return=\aebhome/eqexam.html} -\end{popupmenu} - -\begin{popupmenu}{AeBMenuLocal} - \item{title=AeB, return=\aebhome/webeq.html} - \item{title=-} - \begin{submenu}{title=AeB Pro Family,enabled=false} - \item{title=Home page,return=\aebhome/aeb_pro.html} - \item{title=Graphicxsp,return=\aebhome/graphicxsp.html} - \end{submenu} - \item{title=eqExam,return=\aebhome/eqexam.html} -\end{popupmenu} - -% -% This menu was taken from the Acrobat JavaScript API Reference -% as a test of the new popupmenu and submenu environments. -% -\begin{popupmenu}{myMenu} - \item{title=Item 1, marked, enabled=false} - \item{title=-} - \begin{submenu}{title=Item 2} - \item{title={Item 2, Submenu 1}} - \begin{submenu}{title={Item 2, Submenu 2}} - \item{title={Item 2, Submenu 2, Subsubmenu 1}} - \end{submenu} - \end{submenu} - \item{title=Item 3} - \item{title=Item 4} -\end{popupmenu} - -\begin{insDLJS}[AeBMenu]{md}{Menu Data} -\AeBMenu -\myMenu -\end{insDLJS} - -\parindent0pt\parskip6pt - -\begin{document} - -\maketitle - -This file uses the \textsf{eforms} package to create push buttons, -the push button of \textsf{hyperref} can also be used. - -Here is an example taken from the Acrobat JavaScript API Reference: -\pushButton[\CA{My Menu}\AA{\AAMouseEnter{\JS{% -var cChoice = \popUpMenu(myMenu);\r -if ( cChoice != null ) app.alert("You chose the \\""+cChoice+"\\" menu item"); -}}}]{mymenu}{}{11bp} - -We can add a push button with a rollover effect -\pushButton[\CA{Packages}\AA{\AAMouseEnter{\JS{% -var cChoice = \popUpMenu(AeBMenu);\r -if ( cChoice != null ) app.launchURL(cChoice); -}}}]{menu}{}{11bp} - -You can also open the menu with a link: -\setLinkText[\A{\JS{% -var cChoice = \popUpMenu(AeBMenu);\r -if ( cChoice != null ) app.launchURL(cChoice); -}}]{Package}. Links do not have a rollover effect, however, you can use buttons like so: {\setbox0=\hbox{\textcolor{red}{Packages}}% -\makebox[0pt][l]{\pushButton[\W0\BG{}\BC{}\S{S}\AA{\AAMouseEnter{\JS{% -var cChoice = \popUpMenu(AeBMenu);\r if ( cChoice != null ) -app.launchURL(cChoice); }}}]{menu}{\wd0}{\ht0+\dp0}}\unhbox0}. - -This is a version that has a local version of the menu array: -{\setbox0=\hbox{\textcolor{red}{Packages}}% -\makebox[0pt][l]{\pushButton[\W0\BG{}\BC{}\S{S}\AA{\AAMouseEnter{\JS{% -\AeBMenuLocal\r -var cChoice = \popUpMenu(AeBMenuLocal);\r if ( cChoice != null ) -app.launchURL(cChoice);}}}]{menu}{\wd0}{\ht0+\dp0}}\unhbox0} -\end{document} - -This is a version that has a local version of the menu array: -\PushButton[name=hyperbutton,onmouseover={\AeBMenuLocal -var cChoice = \popUpMenu(AeBMenuLocal); if ( cChoice != null ) -app.launchURL(cChoice); }]{Packages} diff --git a/texmf-dist/source/latex/popupmenu/examples/pumen_ex_pdftex.tex b/texmf-dist/source/latex/popupmenu/examples/pumen_ex_pdftex.tex deleted file mode 100644 index 3254570d..00000000 --- a/texmf-dist/source/latex/popupmenu/examples/pumen_ex_pdftex.tex +++ /dev/null @@ -1,111 +0,0 @@ -\documentclass{article} -\usepackage[designv,pdftex]{web} -\usepackage{eforms} -\usepackage{popupmenu} - -\title{The \texorpdfstring{\textsf{popupmenu}}{popupmenu} Package Test File} -\author{D. P. Story} -\subject{Test file for the popupmenu Package} -\keywords{LaTeX, popupmenu, Acrobat JavaScript, AcroTeX} - -\university{NORTHWEST FLORIDA STATE COLLEGE\\ - Department of Mathematics} -\email{dpstory@acrotex.net} -\version{1.0} - -%\nocopyright -\norevisionLabel - -% -% This package can be used by users of pdftex, dvipdfm, dvips (with distiller) -% - -\urlPath{\aebhome}{http://www.math.uakron.edu/~dpstory} - -\begin{popupmenu}{AeBMenu} - \item{title=AeB, return=\aebhome/webeq.html} - \item{title=-} - \begin{submenu}{title=AeB Pro Family} - \item{title=Home page,return=\aebhome/aeb_pro.html} - \item{title=Graphicxsp,return=\aebhome/graphicxsp.html} - \end{submenu} - \item{title=eqExam,return=\aebhome/eqexam.html} -\end{popupmenu} - -\begin{popupmenu}{AeBMenuLocal} - \item{title=AeB, return=\aebhome/webeq.html} - \item{title=-} - \begin{submenu}{title=AeB Pro Family,enabled=false} - \item{title=Home page,return=\aebhome/aeb_pro.html} - \item{title=Graphicxsp,return=\aebhome/graphicxsp.html} - \end{submenu} - \item{title=eqExam,return=\aebhome/eqexam.html} -\end{popupmenu} - -% -% This menu was taken from the Acrobat JavaScript API Reference -% as a test of the new popupmenu and submenu environments. -% -\begin{popupmenu}{myMenu} - \item{title=Item 1, marked, enabled=false} - \item{title=-} - \begin{submenu}{title=Item 2} - \item{title={Item 2, Submenu 1}} - \begin{submenu}{title={Item 2, Submenu 2}} - \item{title={Item 2, Submenu 2, Subsubmenu 1}} - \end{submenu} - \end{submenu} - \item{title=Item 3} - \item{title=Item 4} -\end{popupmenu} - -\begin{insDLJS}[AeBMenu]{md}{Menu Data} -\AeBMenu -\myMenu -\end{insDLJS} - -\newcommand{\cs}[1]{\texttt{\char`\\#1}} - - -\parindent0pt\parskip6pt - -\begin{document} - -\maketitle - -This file uses the \textsf{hyperref} package to create push buttons, -the push button of \textsf{eforms} can also be used. - - -Here is an example taken from the Acrobat JavaScript API Reference, it uses -the \cs{PushButton} command of \textsf{hyperref}. The script is implemented as -a mouse up event, rather than a rollover event as it appears \cs{PushButton} does not -support rollover. There is a \texttt{onmouseover} key that is supposed to work, but it doesn't. -\PushButton[name=mymenu, -onclick={var cChoice = \popUpMenu(myMenu); -if ( cChoice != null ) app.alert("You chose the \eqbs\eqbs""+cChoice+"\eqbs\eqbs" menu item"); -}]{My Menu} - - -Here is the same example, but using \cs{pushButton}, the button command from the eforms package. -It is implemented as a rollover event. -\pushButton[\CA{My Menu}\AA{\AAMouseEnter{\JS{% -var cChoice = \popUpMenu(myMenu);\r -if ( cChoice != null ) app.alert("You chose the \\""+cChoice+"\\" menu item"); -}}}]{mymenu}{}{11bp} - -We can add a push button with a rollover effect -\pushButton[\CA{Packages}\AA{\AAMouseEnter{\JS{% -var cChoice = \popUpMenu(AeBMenu);\r -if ( cChoice != null ) app.launchURL(cChoice); -}}}]{menu}{}{11bp} - -This is a version that has a local version of the \texttt{AeBMenuLocal} array. -If we place the array as field-level JavaScript, we don't need the \textsf{eforms} package. -Again, this is an \texttt{onclick} event. -\PushButton[name=mymenu,onclick={\AeBMenuLocal; -var cChoice = \popUpMenu(AeBMenuLocal); -if ( cChoice != null ) app.launchURL(cChoice);}]{AeB Local Menu} - -Fancier examples can be found at the \textcolor{blue}{AeB Blog} (\url{www.math.uakron.edu/~dpstory/aebblog.html}). -\end{document} diff --git a/texmf-dist/source/latex/popupmenu/popupmenu.dtx b/texmf-dist/source/latex/popupmenu/popupmenu.dtx index 4ca46a31..f454e67a 100644 --- a/texmf-dist/source/latex/popupmenu/popupmenu.dtx +++ b/texmf-dist/source/latex/popupmenu/popupmenu.dtx @@ -1,10 +1,9 @@ % \iffalse %<*copyright> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% popupmenu.sty package, 2009-10-15 %% -%% Copyright (C) 2009 D. P. Story %% +%% popupmenu.sty package, %% +%% Copyright (C) 2009--2020 %% %% dpstory@acrotex.net %% -%% storyd@nwfsc.edu %% %% %% %% This program can redistributed and/or modified under %% %% the terms of the LaTeX Project Public License %% @@ -15,13 +14,47 @@ % %\NeedsTeXFormat{LaTeX2e} %\ProvidesPackage{popupmenu} -% [2010/09/18 v1.0 Provides support for popup menus (dps)] +% [2020/07/26 v1.2 Provides support for popup menus (dps)] %<*driver> \documentclass{ltxdoc} -\usepackage[colorlinks,hyperindex]{hyperref} -\pdfstringdefDisableCommands{\let\\\textbackslash}% -\EnableCrossrefs \CodelineIndex +\usepackage[colorlinks,hyperindex=false]{hyperref} +\usepackage{fancyvrb} +%\def\texorpdfstring#1#2{#1} +%\pdfstringdefDisableCommands{\let\\\textbackslash} \OnlyDescription % comment out for implementation details +\EnableCrossrefs +\CodelineIndex +\RecordChanges +\InputIfFileExists{aebdocfmt.def}{\PackageInfo{popupmenu}{Inputting aebdocfmt.def}} + {\def\IndexOpt{\DescribeMacro}\def\IndexKey{\DescribeMacro}\let\setupFullwidth\relax + \PackageInfo{popupmenu}{aebdocfmt.def cannot be found}} +\EnableCrossrefs \CodelineIndex \RecordChanges +\makeatletter +\renewcommand{\paragraph} + {\@startsection{paragraph}{4}{0pt}{6pt}{-3pt} + {\normalfont\normalsize\bfseries}} +\renewenvironment{quote}[1][] + {\def\@rgi{#1}\ifx\@rgi\@empty + \let\rghtm\@empty\else\def\rghtm{\rightmargin\leftmargin}\fi + \list{}{\rghtm} %{\rightmargin\leftmargin}% + \item\relax} + {\endlist} +\makeatother +\bgroup\ttfamily +\gdef\brpr#1{\char123\relax#1\char125\relax}\egroup +\let\darg\brpr +\let\env\texttt +\let\opt\texttt +\let\app\textsf +\let\tops\texorpdfstring +\def\nmpsep#1{\hskip-\marginparsep\texttt{#1}} +\def\visispace{\symbol{32}} +\def\ameta#1{\ensuremath{\langle\textit{\texttt{#1}}\rangle}} +\def\meta#1{\textsl{\texttt{#1}}} +\def\SUB#1{\ensuremath{{}_{\mbox{\scriptsize\ttfamily#1}}}} +\def\ltag{<}\def\rtag{>} +\def\EXCL{!} +\let\app\textsf\let\pkg\textsf \begin{document} \GetFileInfo{popupmenu.sty} \title{The \textsf{popupmenu} Package} @@ -32,95 +65,146 @@ \tableofcontents \let\Email\texttt \DocInput{popupmenu.dtx} - \PrintIndex +\IfFileExists{\jobname.ind}{\newpage\setupFullwidth\par\PrintIndex}{\paragraph*{Index} The index goes here. Execute,\\ + \texttt{popupmenu -s gind.ist -o popupmenu.ind popupmenu.idx} on the command line and recompile + \texttt{popupmenu.dtx}.} +\IfFileExists{\jobname.gls}{\PrintChanges}{\paragraph*{Change History} The list of changes goes here. Execute,\\ + \texttt{makeindex -s gglo.ist -o popupmenu.gls popupmenu.glo} on the command line and recompile + \texttt{popupmenu.dtx}.} \end{document} % % \fi +% \MakeShortVerb{|} +% \InputIfFileExists{aebdonotindex.def}{\PackageInfo{ltx4yt}{Inputting aebdonotindex.def}} +% {\PackageInfo{ltx4yt}{cannot find aebdonotindex.def}} +% \DoNotIndex{\g@addto@macro,\divide,\box,\setbox,\x,\y,\z} +% % \begin{macrocode} %<*package> % \end{macrocode} +% \section{Instroduction} % This is a short package that provides environments and commands for building % a popup menu using JavaScript. The command \cs{popUpMenu} uses the Acrobat JavaScript % method \texttt{app.popUpMenuEx}. This latter method requires you to pass to it a % structured menu listing of the menu items to be displayed in the popup menu, and the actions % to be taken when a menu item is selected. The environments \texttt{popupmenu} and % \texttt{submenu} are defined for the purpose of creating this hierarchical structure. +% \changes{v1.1}{2020/07/21}{explicitly require \string\pkg{eforms}} +% \changes{v1.2}{2020/07/26}{Added \string\opt{tracking} option} +% \section{Package Options} % \begin{macrocode} \RequirePackage{xkeyval} +\newif\iftrackingPU \trackingPUfalse +\DeclareOptionX{tracking}{\trackingPUtrue\def\puTracking{true}} +\DeclareOptionX{!tracking}{\trackingPUfalse\def\puTracking{false}} +\def\puTracking{false} +\ProcessOptionsX\relax +\edef\pu@restoreCats{% + \catcode`\noexpand\"=\the\catcode`\"\relax + \catcode`\noexpand\'=\the\catcode`\'\relax + \catcode`\noexpand\,=\the\catcode`\,\relax + \catcode`\noexpand\!=\the\catcode`\!\relax +} +\@makeother\"\@makeother\'\@makeother\,\@makeother\! % \end{macrocode} +% \section{Required packages} +% \begin{macrocode} +\RequirePackage{eforms} +% \end{macrocode} +% \section{The \texorpdfstring{\protect\env}{}{popupmenu} environment} % According to the JavaScript manual, the \texttt{app.popUpMenuEx} method takes % one or more \texttt{MenuItem} objects. The {\LaTeX} access to the properties of this object are documented -% as follows (taken verbatim from the JavaScript reference): -% \begin{macro}{title} +% as follows. This set of keys becomes the \pkg{xkeyval} family \texttt{menustruct} of keys for this package:\par\medskip\noindent +% \leavevmode\IndexKey{title}\nmpsep{=\ameta{string\upshape\string|-}} % The menu item name, which is the string to appear on the menu item. The value of -% \texttt{"-"} is reserved to draw a separator line in the menu. -% \begin{macro}{marked} +% \texttt{"-"} is reserved to draw a separator line in the menu.\par\medskip\noindent +% \leavevmode\IndexKey{marked}\nmpsep{=\ameta{\upshape{true\string|false}}} % (optional) A Boolean value specifying whether the item is to be marked with a -% check. The default is \texttt{false} (not marked). -% \begin{macro}{enabled} +% check. The default is \texttt{false} (not marked).\par\medskip\noindent +% \leavevmode\IndexKey{enabled}\nmpsep{=\ameta{\upshape{true\string|false}}} % (optional) A Boolean value specifying whether the item is to appear enabled or -% grayed out. The default is \texttt{true} (enabled). -% \begin{macro}{return} -% (optional) A string to be returned when the menu item is selected. The default is the -% value of cName. +% grayed out. The default is \texttt{true} (enabled).\par\medskip\noindent +% \leavevmode\IndexKey{return}\nmpsep{=\ameta{string}} +% (optional) A string to be returned when the menu item is selected. If \texttt{return} +% is not specified or has no value, the value of the \texttt{title} key is returned. +% \changes{v1.1}{2020/07/21}{Insert \string\cs{pdfstringdef} in title definition} % \begin{macrocode} -\define@key{menustruct}{title}[]{\def\menustruct@title{#1}} +\def\title@dash{-}\def\puNone{none} +\define@key{menustruct}{title}[]{\Hy@unicodefalse + \let\btitle@dash\ef@NO + \def\@rgi{#1}\ifx\@rgi\title@dash\let\btitle@dash\ef@YES\fi + \pdfstringdef\menustruct@title{#1}} \define@boolkey{menustruct}{marked}[true]{} \define@boolkey{menustruct}{enabled}[true]{} -\define@key{menustruct}{return}[]{\def\menustruct@return{#1}} +\define@key{menustruct}{return}[]{\def\menustruct@return{#1}\relax + \ifx\menustruct@return\puNone\def\menustruct@return{null}\fi} % \end{macrocode} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} % We use the command \cs{pum@holdtoks} to hold the menu items as they are processed % in the environment, and use \cs{@AddToMenuToks} to add to the items. % \begin{macrocode} \let\pum@holdtoks\@empty -\newcommand{\@AddToMenuToks}{\g@addto@macro\pum@holdtoks} +\let\pum@holdtoksEx\@empty +\def\@AddToMenuToks{\g@addto@macro\pum@holdtoks} +\def\@AddToMenuToksEx{\g@addto@macro\pum@holdtoksEx} % \end{macrocode} -% \begin{environment}{popupmenu} +% \begin{environment}{popupmenu}\nmpsep{\,\darg{\ameta{name}}} The \ameta{name} argument should be +% consist of letters only, for \ameta{name} will be made into the command \cs{\ameta{name}}. The \ameta{name} +% has a duel rule, \cs{\ameta{name}} is a macro that expands to a JavaScript array of menu items; and +% the name itself \ameta{name} is the name of a JavaScript variable. % We begin by defining our menu structure using the % \texttt{popupmenu} environment. Within this environment, % we list the items in the menu using \cs{item} and -% the \texttt{submenu} menu if there are sub menus. +% the \texttt{submenu} menu if there are sub-menus. % % The \texttt{popupmenu} command requires one parameter, this command is % used to create both a command and a JavaScript variable. The name is % passed to the \cs{popUpMenu} command, while the command version of the -% name expands to the menu structure. The menu structure can be placed -% at the document level, or as part of a push button action. -% Here is an example of usage:\par -% \begin{verbatim} +% name expands to the menu structure (an array). +% +%There are two ways of passing the array that is the menu structure to \cs{popUpMenu}: +% \begin{enumerate} +% \item From the document level: The arrays are declared at the document level, the +% name of the array is passed as the argument of \cs{popUpMenu(\ameta{menu-array})}. +% \item From the field level: Within the script for a push button, for example, use +% the command version of the array name to expand first, then it can be referenced. +% \end{enumerate} +%\begin{Verbatim}[xleftmargin=\parindent,codes={\catcode`\%=9},commandchars={!()}] %\urlPath{\aebhome}{http://www.math.uakron.edu/~dpstory} %\begin{popupmenu}{myMenu} -% \item{title=AeB,return=\aebhome/webeq.html} -% \item{title=-} -% \begin{submenu}{title=AeB Pro Family} -% \item{title=Home page, return=\aebhome/aeb_pro.html} -% \item{title=Graphicxsp, return=\aebhome/graphicxsp.html} -% \end{submenu} -% \item{title=eqExam, return=\aebhome/eqexam.html} +% \item{title=AeB,return=\aebhome/webeq.html} +% \item{title=-} +% \begin{submenu}{title=AeB Pro Family} +% \item{title=Home page, return=\aebhome/aeb_pro.html} +% \item{title=Graphicxsp, return=\aebhome/graphicxsp.html} +% \end{submenu} +% \item{title=eqExam, return=\aebhome/eqexam.html} %\end{popupmenu} -%\end{verbatim} +%\puUseMenus{myMenu} !% preamble +%\end{Verbatim} +%The \cs{puUseMenus} declares that \texttt{myMenu} is to be embedded in the PDF as document JavaScript. +%If \cs{puUseMenus} is not expanded in the preamble %The above definition can be conveniently placed in the preamble, though it can % appear anywhere before it is used, obviously. Now to use the menu structure, % all we need is a push button or link to create a JavaScript action: -%\begin{verbatim} -% \pushButton[\CA{Packages}\AA{\AAMouseEnter{\JS{% -% \myMenu\r -% var cChoice = \popUpMenu(myMenu);\r -% if ( cChoice != null ) app.launchURL(cChoice); -% }}}]{menu}{}{11bp} -%\end{verbatim} +%\begin{Verbatim}[xleftmargin=\parindent,codes={\catcode`\%=9},commandchars={|~@}] +%\pushButton[\CA{Packages}\AAmouseenter{|% +% var cChoice = \popUpMenu(myMenu);\r +% if ( cChoice != null ) app.launchURL(cChoice); +%}]{menu}{}{11bp} +%\end{Verbatim} % The above example uses the \textsf{eforms} package, but a push button from \textsf{hyperref} will do too. % The \texttt{app.popUpMenuEx} method returns the return value, which we, in turn, process. In this % case, the return is a URL, which we launch. % -% If we have placed \cs{myMenu} at the document level, the line \verb!\myMenu\r! would not be needed. -% If you are using the same menu several times in the document, put it at the document level to reduce -% file size. -% +% Now, if we did not place \cs{puUseMenus\darg{myMenu}} in the preamble, it can be used at the field level. +% The push button above would then need to be, +%\begin{Verbatim}[xleftmargin=\parindent,codes={\catcode`\%=9},commandchars={|~@}] +%\pushButton[\CA{Packages}\AAmouseenter{|% +% \myMenu\r +% var cChoice = \popUpMenu(myMenu);\r +% if ( cChoice != null ) app.launchURL(cChoice); +%}]{menu}{}{11bp} +%\end{Verbatim} % Also, in the above example, you see how the name, \texttt{myMenu}, passed as an argument % of the popupmenu environment is used as a name and as a command: The name is passed to % \cs{popUpMenu}, while the command expands to the menu structure that is referenced by the name. @@ -131,7 +215,7 @@ % the index of the menu structure array; for example, % \cs{itemindex} might expand to \texttt{[0]}, \texttt{[1].oSubMenu[3]}, or \texttt{[2].oSubMenu[3].oSubMenu[0]}. % If \cs{itemindex} is included in the return value (possibly as an array entry), we can -% know the item the use selected +% know the item the user selected. %\begin{verbatim} %var aChoice=processMenu(AeBMenu); %if (aChoice!=null) { @@ -141,49 +225,79 @@ %} %\end{verbatim} % The above code gets the return array, then uses it to get the title of the item -% selected, +% selected. % \begin{macrocode} \newcount\pum@cnt \def\pum@updateindex{\global\advance\pum@cnt\@ne \edef\pum@rc{\pum@topindex[\the\pum@cnt]}\edef\itemindex{'\pum@rc'}} -\def\pum@initIndexMenu#1{\global\pum@cnt=-1\relax\edef\pum@rc{#1}% +\def\pum@initIndexMenu#1{\global\pum@cnt=\m@ne\edef\pum@rc{#1}% \edef\pum@topindex{\pum@rc}} % \end{macrocode} % \end{macro} % We are now ready to define the \texttt{popupmenu} environment. The environment % takes one required parameter, a name that is used as a JavaScript variable. % This name is also used to create a command. +% \changes{v1.1}{2020/07/21}{Local definition of \string\cs{Esc} and \string\cs{cs}} % \begin{macrocode} -\newenvironment{popupmenu}[1]{\pum@initIndexMenu{}% - \let\pum@holdtoks\@empty - \toks@={\pum@mytab}\@makeother\~ +\newcount\submenuLevel \submenuLevel\z@ +\newenvironment{popupmenu}[1]{\pum@initIndexMenu{}\submenuLevel\z@ + \ifpdfmarkup + \def\textbackslash{\eqbs}\relax + \def\Esc{\textbackslash}\relax + \def\csiv{\eqbs\eqbs}\relax + \def\cs##1{\csiv\csiv##1}\else + \def\Esc{\eqbs\eqbs}\def\cs{\Esc\Esc}\fi + \let\pum@holdtoks\@empty\let\pum@holdtoksEx\@empty + \toks@={\pum@mytab}\@temptokena={\pum@mytab}\@makeother\~% % \end{macrocode} % We initialize with a \cs{@gobble}, which eats up the leading comma (,) % that is placed there by the code below. % \begin{macrocode} - \gdef\msarg{#1}\@AddToMenuToks{\@gobble}% - \let\item\pum@item -}{% - \expandafter\xdef\csname\msarg\endcsname{% - var \msarg\space = [ \pum@holdtoks^^J];}% -} + \gdef\msarg{#1}\gdef\msargEx{#1Ex}\@AddToMenuToks{\@gobble}% + \@AddToMenuToksEx{\@gobble}\let\item\pum@item +\ignorespaces}{% + \csarg\xdef{\msarg}{var \msarg\space = [ \pum@holdtoks^^J];}% + \iftrackingPU + \csarg\xdef{\msargEx}{var \msargEx\space = [ \pum@holdtoksEx^^J];}\fi +\aftergroup\ignorespaces} % \end{macrocode} % \end{environment} -% \begin{macro}{\pum@item} -% At the startup of the \texttt{popupmenu} environment, we \verb|\let\item\pum@item|. -% The definition of \cs{pum@item} takes one argument, the properties described above. +% \begin{macro}{\item}\nmpsep{\small\,\darg{title=\ameta{string},marked=\ameta{\upshape{true\string|false}},enabled=\ameta{\upshape{true\string|false}},return=\ameta{string}}}\\ +% Below is the definition of \cs{pum@item}, at the startup of the +% \env{popupmenu} environment, we \verb|\let\item\pum@item|. +% The definition of \DescribeMacro\pum@item\cs{pum@item} takes one argument, the properties described above. % \begin{macrocode} \newcommand{\pum@item}[1]{\pum@updateindex - \edef\tmp@exp{\noexpand - \setkeys{menustruct}{title,marked=false,enabled,return,#1}}\tmp@exp - \edef\tmp@exp{,^^J\the\toks@ - {cName: "\menustruct@title"% - \ifKV@menustruct@marked, bMarked: true\fi% - \ifKV@menustruct@enabled\else, bEnabled: false\fi% - \ifx\menustruct@return\@empty\else, - cReturn: "\menustruct@return"\fi}}% - \expandafter\@AddToMenuToks\expandafter{\tmp@exp}% -} +% \edef\tmp@exp{\noexpand +% \setkeys{menustruct}{title,marked=false,enabled,return,#1}}\tmp@exp + \setkeys{menustruct}{title,marked=false,enabled,return,#1}\relax + \ifx\menustruct@title\@empty + \PackageWarning{popupmenu} + {A value of the key 'title' is required,\MessageBreak + putting in a place keeper title}% + \def\menustruct@title{This title is undefined}\fi + \edef\tmp@exp{,^^J\the\toks@ + {cName: "\menustruct@title"% + \ifKV@menustruct@marked, bMarked: true\fi% + \ifKV@menustruct@enabled\else, bEnabled: false\fi% +% \ifx\btitle@dash\ef@NO, cItem: \itemindex\fi% + \ifx\menustruct@return\@empty\else,% + cReturn: "\menustruct@return"\fi}}\expandafter + \@AddToMenuToks\expandafter{\tmp@exp}% +% \end{macrocode} +%\changes{v1.1}{2020/07/21}{create extended arrays} +% \begin{macrocode} + \edef\tmp@expEx{,^^J\the\@temptokena + {cName: "\menustruct@title"% + \ifKV@menustruct@marked, bMarked: true\fi% + \ifKV@menustruct@enabled\else, bEnabled: false\fi% +% \ifx\btitle@dash\ef@NO, cItem: \itemindex\fi% + \ifx\btitle@dash\ef@NO + \ifx\menustruct@return\@empty,% + cReturn:"[\itemindex,'\menustruct@title']"% + \else,cReturn:"[\itemindex,'\menustruct@return']"\fi\fi}}% + \expandafter\@AddToMenuToksEx\expandafter{\tmp@expEx}% +\ignorespaces} % \end{macrocode} % \end{macro} % Some technical matters, we need unmatched braces, so we define @@ -195,60 +309,175 @@ \endgroup \def\pum@mytab{\space\space\space\space} % \end{macrocode} -% \begin{environment}{submenu} +% \begin{environment}{submenu}\nmpsep{\,\darg{title=\ameta{title},marked=\ameta{\upshape{true\string|false}}}}\\ % Used to create a submenu of a menu item. The top level menu item has no return value, -% it can be marked but cannot be dis-enabled (\texttt{enabled=false}). +% it can be marked but cannot be disabled (\texttt{enabled=false}). % % The argument of \texttt{submenu} are any of the menu item properties, however, only % \texttt{title} and \texttt{marked} will be recognized. % % The JavaScript property, \texttt{oSubMenu}, of the menu structure passed to % the method \texttt{app.popUpMenuEx} has no {\LaTeX} counterpart. This property -% key-value pair is automatically inserted by the \texttt{submenu} +% key-value pair is automatically inserted by the \env{submenu} % environment. % \begin{macrocode} -\newenvironment{submenu}[1]{\pum@updateindex - \xdef\saved@pum@cnt{\the\pum@cnt}% - \pum@initIndexMenu{\pum@rc.oSubMenu}\edef\temp@toks{\the\toks@}% - \toks@=\expandafter{\temp@toks\pum@mytab}% - \setkeys{menustruct}{title,marked=false,enabled,return,#1}% - \edef\tmp@exp{,^^J\the\toks@ - \noexpand\pum@lbrace cName: "\menustruct@title"% - \ifKV@menustruct@marked, bMarked: true\fi% - \ifKV@menustruct@enabled\else, bEnabled: false\fi, - oSubMenu:^^J\the\toks@[}% +\newenvironment{submenu}[1]{\pum@updateindex\advance\submenuLevel\@ne + \csarg\xdef{pum@cntLevel\the\submenuLevel}{\the\pum@cnt}% +% \xdef\saved@pum@cnt{\the\pum@cnt}\relax + \pum@initIndexMenu{\pum@rc.oSubMenu}\edef\temp@toks{\the\toks@}% + \def\temp@toksEx{\the\@temptokena}% + \toks@=\expandafter{\temp@toks\pum@mytab}% + \@temptokena=\expandafter{\temp@toksEx\pum@mytab}% + \setkeys{menustruct}{title,marked=false,enabled,return,#1}% + \edef\tmp@exp{,^^J\the\toks@ + \noexpand\pum@lbrace cName: "\menustruct@title"% + \ifKV@menustruct@marked, bMarked: true\fi% + \ifKV@menustruct@enabled\else, bEnabled: false\fi, + oSubMenu:^^J\the\toks@[}% % \end{macrocode} % Again, we \cs{@gobble} up the leading comma (,). % \begin{macrocode} - \expandafter\@AddToMenuToks\expandafter{\tmp@exp\@gobble}% -}{% - \edef\tmp@exp{^^J\the\toks@ ]\pum@rbrace}% - \expandafter\@AddToMenuToks\expandafter{\tmp@exp}% - \global\pum@cnt\saved@pum@cnt -} + \expandafter\@AddToMenuToks\expandafter{\tmp@exp\@gobble}% +% \end{macrocode} +% \begin{macrocode} + \edef\tmp@expEx{,^^J\the\@temptokena + \noexpand\pum@lbrace cName: "\menustruct@title"% + \ifKV@menustruct@marked, bMarked: true\fi% + \ifKV@menustruct@enabled\else, bEnabled: false\fi, + oSubMenu:^^J\the\@temptokena[}% + \expandafter\@AddToMenuToksEx\expandafter{\tmp@expEx\@gobble}% +\ignorespaces}{% + \edef\tmp@exp{^^J\the\toks@ ]\pum@rbrace}% + \edef\tmp@expEx{^^J\the\@temptokena ]\pum@rbrace}% + \expandafter\@AddToMenuToks\expandafter{\tmp@exp}% + \expandafter\@AddToMenuToksEx\expandafter{\tmp@expEx}% + \global\pum@cnt\@nameuse{pum@cntLevel\the\submenuLevel}% +\aftergroup\ignorespaces} % \end{macrocode} % \end{environment} -% \begin{macro}{\popUpMenu} -% The \cs{popUpMenu} command takes one argument, the name pass to a -% popupmenu environment. The command expands to the \texttt{app.popUpMenuEx} -% method. The document author must then process the return value in some way. +% \begin{macro}{\popUpMenu}\nmpsep{(\ameta{name})} +% The \cs{popUpMenu} command takes one argument, the \ameta{name} that had +% earlier been passed to a \env{popupmenu} environment. The command expands to the +% \texttt{app.popUpMenuEx} method. The document author must then process the return value in some way. % The argument is enclosed in parentheses, this is so we can use \cs{popUpMenu} % at the document level, we can pass it an argument there. % \begin{macrocode} \def\popUpMenu(#1){app.popUpMenuEx.apply( app, #1 )} % \end{macrocode} % \end{macro} -% \begin{macro}{\urlPath} +% \begin{macro}{\puProcessMenu}\nmpsep{(\ameta{name})} +% When the \opt{tracking} option is taken, use the \cs{puProcessMenu} command to execute +% a menu item with tracking. If \opt{tracking} is not in effect, \cs{puProcessMenu} is the +% same as \cs{popUpMenu}. +% \begin{macrocode} +\def\puProcessMenu(#1){\iftrackingPU + puProcessMenu("#1")\else\popUpMenu(#1)\fi} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\urlPath}\nmpsep{\darg{\ameta{path}}} % A convenience command to save a url path. The string is normalized using % the \textsf{hyperref} command \cs{hyper@normalise}. Though we don't require -% any other packages, you can't do much unless you use \textsf{hyperref} as well. +% any other packages, you can't do much unless you use \textsf{hyperref}. % \begin{macrocode} \providecommand{\urlPath}[1]{\def\pum@urlName{#1}% - \hyper@normalise\pum@urlPath} + \hyper@normalise\pum@urlPath} +%\def\pum@urlPath#1{\csarg\xdef\pum@urlName{#1}} \def\pum@urlPath#1{\expandafter\xdef\pum@urlName{#1}} % \end{macrocode} % \end{macro} +% \leavevmode\DescribeMacro\puUseMenus\nmpsep{\ameta{list-arrays}}, where \ameta{list-arrays} +% is a comma-delimited list of \ameta{name}s that have been declared earlier as an argument +% of a \env{popupmenu} environment. The arrays listed in \ameta{list-arrays} will be defined at +% the document level. +% \begin{macrocode} +\def\puUseTheseMenus{// No pop-up data defined^^J} +\let\puMenuCmds\@empty +\newcommand{\puUseMenus}[1]{\bgroup + \@for\pu@menu:=#1\do{\ifx\puMenuCmds\@empty + \def\puUseTheseMenus{// popupmenu: Begin popup menu data^^J}\fi + \expandafter\g@addto@macro\expandafter + \puMenuCmds\expandafter{% + \csname\pu@menu\endcsname^^J}\relax +% \end{macrocode} +% \begin{macrocode} + \iftrackingPU + \expandafter\g@addto@macro\expandafter + \puMenuCmds\expandafter{% + \csname\pu@menu Ex\endcsname^^J}\relax + \fi +% \end{macrocode} +% \begin{macrocode} + \edef\x{\expandafter\noexpand\@nameuse{\pu@menu}}% + \toks@=\expandafter{\x^^J}% + \expandafter\g@addto@macro\expandafter + \puUseTheseMenus\expandafter{\the\toks@}% +% \end{macrocode} +% \begin{macrocode} + \iftrackingPU + \edef\x{\expandafter\noexpand\@nameuse{\pu@menu Ex}}% + \toks@=\expandafter{\x^^J}% + \expandafter\g@addto@macro\expandafter + \puUseTheseMenus\expandafter{\the\toks@}% + \fi + }\g@addto@macro\puUseTheseMenus + {// popupmenu: End of popup menu data}\egroup + \ifx\puUseTheseMenus\@empty + \def\puUseTheseMenus{// No pop-up data defined}\fi +} +% \end{macrocode} +% A small \env{insDLJS} environment to create the menu arrays at the document level. +% The command \cs{puUseTheseMenus} will expand to the array declarations. +% \begin{macrocode} +\iftrackingPU +\begin{insDLJS}{pujs}{Pop-up Menu Data} +\puUseTheseMenus +\end{insDLJS} +\@onlypreamble\puUseMenus +\begin{insDLJS*}{pumenu} +\begin{newsegment}{popupmenu: Menu tracking support} +var trackingPU=\puTracking; +var PUdebug=false; +var aPULastChoice=new Array; +var bPULastChoice=false; +var bIsMarked=false; +%var aChoice; // make local +function puProcessMenu(cMenu) { // aMenu->cMenu now a string + var cMenuEx=(trackingPU)?cMenu+"Ex":cMenu; + var aMenuEx=eval(cMenuEx); + var cChoice = app.popUpMenuEx.apply( app, aMenuEx ); + if (trackingPU) { + if ( cChoice != null ) { + aChoice=eval(cChoice); + if (aChoice[1]==""||aChoice[1]=="null") return null; + var puRtn=aChoice[1]; + var thisChoice=aChoice[0]; +// eval(cMenuEx+thisChoice).bMarked=true; + if (!bPULastChoice) { + eval(cMenuEx+aChoice[0]).bMarked=true; + } else { + var structLoc=aPULastChoice[1]; + if(aPULastChoice[0]+structLoc==cMenuEx+aChoice[0]) { + bIsMarked = eval(cMenuEx+aChoice[0]).bMarked; + eval(cMenuEx+aChoice[0]).bMarked=!(bIsMarked); + bPULastChoice=false; + if (bIsMarked) var puRtn=null + } else { + eval(aPULastChoice[0]+structLoc).bMarked=false; + eval(cMenuEx+aChoice[0]).bMarked=true; + } + } + aPULastChoice=[cMenuEx,aChoice[0]]; + bPULastChoice=true; + return puRtn; + } else return null; + } else return cChoice; +} +\end{newsegment} +\end{insDLJS*} +\fi +% \end{macrocode} % \begin{macrocode} +\pu@restoreCats % % \end{macrocode} % \Finale diff --git a/texmf-dist/tex/latex/popupmenu/popupmenu.sty b/texmf-dist/tex/latex/popupmenu/popupmenu.sty index 49dbb8d5..c2202755 100644 --- a/texmf-dist/tex/latex/popupmenu/popupmenu.sty +++ b/texmf-dist/tex/latex/popupmenu/popupmenu.sty @@ -1,83 +1,210 @@ -%% -%% This is file `popupmenu.sty', -%% generated with the docstrip utility. -%% -%% The original source files were: -%% -%% popupmenu.dtx (with options: `copyright,package') -%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% popupmenu.sty package, 2009-10-15 %% -%% Copyright (C) 2009 D. P. Story %% -%% dpstory@acrotex.net %% -%% storyd@nwfsc.edu %% -%% %% -%% This program can redistributed and/or modified under %% -%% the terms of the LaTeX Project Public License %% -%% Distributed from CTAN archives in directory %% -%% macros/latex/base/lppl.txt; either version 1 of the %% -%% License, or (at your option) any later version. %% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{popupmenu} - [2010/09/18 v1.0 Provides support for popup menus (dps)] -\RequirePackage{xkeyval} -\define@key{menustruct}{title}[]{\def\menustruct@title{#1}} -\define@boolkey{menustruct}{marked}[true]{} -\define@boolkey{menustruct}{enabled}[true]{} -\define@key{menustruct}{return}[]{\def\menustruct@return{#1}} -\let\pum@holdtoks\@empty -\newcommand{\@AddToMenuToks}{\g@addto@macro\pum@holdtoks} -\newcount\pum@cnt -\def\pum@updateindex{\global\advance\pum@cnt\@ne - \edef\pum@rc{\pum@topindex[\the\pum@cnt]}\edef\itemindex{'\pum@rc'}} -\def\pum@initIndexMenu#1{\global\pum@cnt=-1\relax\edef\pum@rc{#1}% - \edef\pum@topindex{\pum@rc}} -\newenvironment{popupmenu}[1]{\pum@initIndexMenu{}% - \let\pum@holdtoks\@empty - \toks@={\pum@mytab}\@makeother\~ - \gdef\msarg{#1}\@AddToMenuToks{\@gobble}% - \let\item\pum@item -}{% - \expandafter\xdef\csname\msarg\endcsname{% - var \msarg\space = [ \pum@holdtoks^^J];}% -} -\newcommand{\pum@item}[1]{\pum@updateindex - \edef\tmp@exp{\noexpand - \setkeys{menustruct}{title,marked=false,enabled,return,#1}}\tmp@exp - \edef\tmp@exp{,^^J\the\toks@ - {cName: "\menustruct@title"% - \ifKV@menustruct@marked, bMarked: true\fi% - \ifKV@menustruct@enabled\else, bEnabled: false\fi% - \ifx\menustruct@return\@empty\else, - cReturn: "\menustruct@return"\fi}}% - \expandafter\@AddToMenuToks\expandafter{\tmp@exp}% -} -\begingroup -\catcode`<=1 \catcode`\>=2 \@makeother\{ \@makeother\} -\gdef\pum@lbrace<{>\gdef\pum@rbrace<}> -\endgroup -\def\pum@mytab{\space\space\space\space} -\newenvironment{submenu}[1]{\pum@updateindex - \xdef\saved@pum@cnt{\the\pum@cnt}% - \pum@initIndexMenu{\pum@rc.oSubMenu}\edef\temp@toks{\the\toks@}% - \toks@=\expandafter{\temp@toks\pum@mytab}% - \setkeys{menustruct}{title,marked=false,enabled,return,#1}% - \edef\tmp@exp{,^^J\the\toks@ - \noexpand\pum@lbrace cName: "\menustruct@title"% - \ifKV@menustruct@marked, bMarked: true\fi% - \ifKV@menustruct@enabled\else, bEnabled: false\fi, - oSubMenu:^^J\the\toks@[}% - \expandafter\@AddToMenuToks\expandafter{\tmp@exp\@gobble}% -}{% - \edef\tmp@exp{^^J\the\toks@ ]\pum@rbrace}% - \expandafter\@AddToMenuToks\expandafter{\tmp@exp}% - \global\pum@cnt\saved@pum@cnt -} -\def\popUpMenu(#1){app.popUpMenuEx.apply( app, #1 )} -\providecommand{\urlPath}[1]{\def\pum@urlName{#1}% - \hyper@normalise\pum@urlPath} -\def\pum@urlPath#1{\expandafter\xdef\pum@urlName{#1}} -\endinput -%% -%% End of file `popupmenu.sty'. +%% +%% This is file `popupmenu.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% popupmenu.dtx (with options: `copyright,package') +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% popupmenu.sty package, %% +%% Copyright (C) 2009--2020 %% +%% dpstory@acrotex.net %% +%% %% +%% This program can redistributed and/or modified under %% +%% the terms of the LaTeX Project Public License %% +%% Distributed from CTAN archives in directory %% +%% macros/latex/base/lppl.txt; either version 1 of the %% +%% License, or (at your option) any later version. %% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{popupmenu} + [2020/07/26 v1.2 Provides support for popup menus (dps)] +\RequirePackage{xkeyval} +\newif\iftrackingPU \trackingPUfalse +\DeclareOptionX{tracking}{\trackingPUtrue\def\puTracking{true}} +\DeclareOptionX{!tracking}{\trackingPUfalse\def\puTracking{false}} +\def\puTracking{false} +\ProcessOptionsX\relax +\edef\pu@restoreCats{% + \catcode`\noexpand\"=\the\catcode`\"\relax + \catcode`\noexpand\'=\the\catcode`\'\relax + \catcode`\noexpand\,=\the\catcode`\,\relax + \catcode`\noexpand\!=\the\catcode`\!\relax +} +\@makeother\"\@makeother\'\@makeother\,\@makeother\! +\RequirePackage{eforms} +\def\title@dash{-}\def\puNone{none} +\define@key{menustruct}{title}[]{\Hy@unicodefalse + \let\btitle@dash\ef@NO + \def\@rgi{#1}\ifx\@rgi\title@dash\let\btitle@dash\ef@YES\fi + \pdfstringdef\menustruct@title{#1}} +\define@boolkey{menustruct}{marked}[true]{} +\define@boolkey{menustruct}{enabled}[true]{} +\define@key{menustruct}{return}[]{\def\menustruct@return{#1}\relax + \ifx\menustruct@return\puNone\def\menustruct@return{null}\fi} +\let\pum@holdtoks\@empty +\let\pum@holdtoksEx\@empty +\def\@AddToMenuToks{\g@addto@macro\pum@holdtoks} +\def\@AddToMenuToksEx{\g@addto@macro\pum@holdtoksEx} +\newcount\pum@cnt +\def\pum@updateindex{\global\advance\pum@cnt\@ne + \edef\pum@rc{\pum@topindex[\the\pum@cnt]}\edef\itemindex{'\pum@rc'}} +\def\pum@initIndexMenu#1{\global\pum@cnt=\m@ne\edef\pum@rc{#1}% + \edef\pum@topindex{\pum@rc}} +\newcount\submenuLevel \submenuLevel\z@ +\newenvironment{popupmenu}[1]{\pum@initIndexMenu{}\submenuLevel\z@ + \ifpdfmarkup + \def\textbackslash{\eqbs}\relax + \def\Esc{\textbackslash}\relax + \def\csiv{\eqbs\eqbs}\relax + \def\cs##1{\csiv\csiv##1}\else + \def\Esc{\eqbs\eqbs}\def\cs{\Esc\Esc}\fi + \let\pum@holdtoks\@empty\let\pum@holdtoksEx\@empty + \toks@={\pum@mytab}\@temptokena={\pum@mytab}\@makeother\~% + \gdef\msarg{#1}\gdef\msargEx{#1Ex}\@AddToMenuToks{\@gobble}% + \@AddToMenuToksEx{\@gobble}\let\item\pum@item +\ignorespaces}{% + \csarg\xdef{\msarg}{var \msarg\space = [ \pum@holdtoks^^J];}% + \iftrackingPU + \csarg\xdef{\msargEx}{var \msargEx\space = [ \pum@holdtoksEx^^J];}\fi +\aftergroup\ignorespaces} +\newcommand{\pum@item}[1]{\pum@updateindex + \setkeys{menustruct}{title,marked=false,enabled,return,#1}\relax + \ifx\menustruct@title\@empty + \PackageWarning{popupmenu} + {A value of the key 'title' is required,\MessageBreak + putting in a place keeper title}% + \def\menustruct@title{This title is undefined}\fi + \edef\tmp@exp{,^^J\the\toks@ + {cName: "\menustruct@title"% + \ifKV@menustruct@marked, bMarked: true\fi% + \ifKV@menustruct@enabled\else, bEnabled: false\fi% + \ifx\menustruct@return\@empty\else,% + cReturn: "\menustruct@return"\fi}}\expandafter + \@AddToMenuToks\expandafter{\tmp@exp}% + \edef\tmp@expEx{,^^J\the\@temptokena + {cName: "\menustruct@title"% + \ifKV@menustruct@marked, bMarked: true\fi% + \ifKV@menustruct@enabled\else, bEnabled: false\fi% + \ifx\btitle@dash\ef@NO + \ifx\menustruct@return\@empty,% + cReturn:"[\itemindex,'\menustruct@title']"% + \else,cReturn:"[\itemindex,'\menustruct@return']"\fi\fi}}% + \expandafter\@AddToMenuToksEx\expandafter{\tmp@expEx}% +\ignorespaces} +\begingroup +\catcode`<=1 \catcode`\>=2 \@makeother\{ \@makeother\} +\gdef\pum@lbrace<{>\gdef\pum@rbrace<}> +\endgroup +\def\pum@mytab{\space\space\space\space} +\newenvironment{submenu}[1]{\pum@updateindex\advance\submenuLevel\@ne + \csarg\xdef{pum@cntLevel\the\submenuLevel}{\the\pum@cnt}% + \pum@initIndexMenu{\pum@rc.oSubMenu}\edef\temp@toks{\the\toks@}% + \def\temp@toksEx{\the\@temptokena}% + \toks@=\expandafter{\temp@toks\pum@mytab}% + \@temptokena=\expandafter{\temp@toksEx\pum@mytab}% + \setkeys{menustruct}{title,marked=false,enabled,return,#1}% + \edef\tmp@exp{,^^J\the\toks@ + \noexpand\pum@lbrace cName: "\menustruct@title"% + \ifKV@menustruct@marked, bMarked: true\fi% + \ifKV@menustruct@enabled\else, bEnabled: false\fi, + oSubMenu:^^J\the\toks@[}% + \expandafter\@AddToMenuToks\expandafter{\tmp@exp\@gobble}% + \edef\tmp@expEx{,^^J\the\@temptokena + \noexpand\pum@lbrace cName: "\menustruct@title"% + \ifKV@menustruct@marked, bMarked: true\fi% + \ifKV@menustruct@enabled\else, bEnabled: false\fi, + oSubMenu:^^J\the\@temptokena[}% + \expandafter\@AddToMenuToksEx\expandafter{\tmp@expEx\@gobble}% +\ignorespaces}{% + \edef\tmp@exp{^^J\the\toks@ ]\pum@rbrace}% + \edef\tmp@expEx{^^J\the\@temptokena ]\pum@rbrace}% + \expandafter\@AddToMenuToks\expandafter{\tmp@exp}% + \expandafter\@AddToMenuToksEx\expandafter{\tmp@expEx}% + \global\pum@cnt\@nameuse{pum@cntLevel\the\submenuLevel}% +\aftergroup\ignorespaces} +\def\popUpMenu(#1){app.popUpMenuEx.apply( app, #1 )} +\def\puProcessMenu(#1){\iftrackingPU + puProcessMenu("#1")\else\popUpMenu(#1)\fi} +\providecommand{\urlPath}[1]{\def\pum@urlName{#1}% + \hyper@normalise\pum@urlPath} +\def\pum@urlPath#1{\expandafter\xdef\pum@urlName{#1}} +\def\puUseTheseMenus{// No pop-up data defined^^J} +\let\puMenuCmds\@empty +\newcommand{\puUseMenus}[1]{\bgroup + \@for\pu@menu:=#1\do{\ifx\puMenuCmds\@empty + \def\puUseTheseMenus{// popupmenu: Begin popup menu data^^J}\fi + \expandafter\g@addto@macro\expandafter + \puMenuCmds\expandafter{% + \csname\pu@menu\endcsname^^J}\relax + \iftrackingPU + \expandafter\g@addto@macro\expandafter + \puMenuCmds\expandafter{% + \csname\pu@menu Ex\endcsname^^J}\relax + \fi + \edef\x{\expandafter\noexpand\@nameuse{\pu@menu}}% + \toks@=\expandafter{\x^^J}% + \expandafter\g@addto@macro\expandafter + \puUseTheseMenus\expandafter{\the\toks@}% + \iftrackingPU + \edef\x{\expandafter\noexpand\@nameuse{\pu@menu Ex}}% + \toks@=\expandafter{\x^^J}% + \expandafter\g@addto@macro\expandafter + \puUseTheseMenus\expandafter{\the\toks@}% + \fi + }\g@addto@macro\puUseTheseMenus + {// popupmenu: End of popup menu data}\egroup + \ifx\puUseTheseMenus\@empty + \def\puUseTheseMenus{// No pop-up data defined}\fi +} +\iftrackingPU +\begin{insDLJS}{pujs}{Pop-up Menu Data} +\puUseTheseMenus +\end{insDLJS} +\@onlypreamble\puUseMenus +\begin{insDLJS*}{pumenu} +\begin{newsegment}{popupmenu: Menu tracking support} +var trackingPU=\puTracking; +var PUdebug=false; +var aPULastChoice=new Array; +var bPULastChoice=false; +var bIsMarked=false; +function puProcessMenu(cMenu) { // aMenu->cMenu now a string + var cMenuEx=(trackingPU)?cMenu+"Ex":cMenu; + var aMenuEx=eval(cMenuEx); + var cChoice = app.popUpMenuEx.apply( app, aMenuEx ); + if (trackingPU) { + if ( cChoice != null ) { + aChoice=eval(cChoice); + if (aChoice[1]==""||aChoice[1]=="null") return null; + var puRtn=aChoice[1]; + var thisChoice=aChoice[0]; +// eval(cMenuEx+thisChoice).bMarked=true; + if (!bPULastChoice) { + eval(cMenuEx+aChoice[0]).bMarked=true; + } else { + var structLoc=aPULastChoice[1]; + if(aPULastChoice[0]+structLoc==cMenuEx+aChoice[0]) { + bIsMarked = eval(cMenuEx+aChoice[0]).bMarked; + eval(cMenuEx+aChoice[0]).bMarked=!(bIsMarked); + bPULastChoice=false; + if (bIsMarked) var puRtn=null + } else { + eval(aPULastChoice[0]+structLoc).bMarked=false; + eval(cMenuEx+aChoice[0]).bMarked=true; + } + } + aPULastChoice=[cMenuEx,aChoice[0]]; + bPULastChoice=true; + return puRtn; + } else return null; + } else return cChoice; +} +\end{newsegment} +\end{insDLJS*} +\fi +\pu@restoreCats +\endinput +%% +%% End of file `popupmenu.sty'. -- cgit v1.2.3