Re: [NTG-context] Widgets: Any good examples for developing JS-enabled PDFs that calculate?

2019-11-17 Thread Paul Mazaitis


Hi everyone,

First: apologies for the long email; this got a little complicated.

Summary: there may be a bug in setting up calculate field for widgets?

Parts:

 - calculator.tex
 - A M(N)WE
 - The MWE Only Sort of Works

# calculator.tex

On 13 Nov 2019, at 10:26, Pablo Rodriguez wrote:


Hi Paul,



I wonder whether
tex/texmf-context/doc/context/examples/calculator/calculator.tex from
the ConTeXt Suite might be what you look for.

Just in case it helps,


It does (and is quite something!); it's not quite what I need, though. 
I'd like to take advantage of the internal _calculate_ event when a 
field updates - the calculator.tex PDF appears to be entirely 
programmatically event driven?


(Which could certainly work for my application, but I want to try to 
keep this as simple for the user as possible.)



Pablo


# A M(N)WE

Here's a Minimal Working Example, with some caveats:

--- begin MWE ---

\usemodule[fields]

\starttext

\setupinteraction [state=start]

\startJScode{tallyUp}
  var a_fld = this.getField("A");
  var b_fld = this.getField("B");
  event.value = a_fld.value + b_fld.value;
\stopJScode

\setupfield[numField][reset,horizontal]
[height=2pc,rulethickness=1pt,framecolor=lightgrey]

\setupfield[totalField][reset,horizontal]
[
height=2pc,
rulethickness=1pt,
framecolor=lightgrey,
option=readonly,
calculate=JS(tallyUp),
]

\definefield[A][line][numField][]
\definefield[B][line][numField][]

\definefield[Total][line][totalField][]

A: \field[A]

B: \field[B]

\blank[big]

Total: \field[Total]

\stoptext

---  end MWE  ---

The idea here is that the resulting PDF will have three fields: A, B, 
and Total. Whenever a value is placed in A and/or B, on blur the value 
in Total will get updated automatically.


# The MWE Only Sort of Works

Things that are working:

 - I can put values in A and B
 - I can't directly manipulate Total (read-only seems to be working 
fine)


Thing that doesn't work:

 - Total does not get automatically updated (for _any_ of the 
JS-enabled/tolerant PDF viewers I have.)



Upon closer inspection of the resulting PDF with PDF Studio 2019 (I 
don't have Acrobat Pro at the moment), I can confirm some things:


 - The appropriate JavaScript is placed in the form, as a custom 
calculation script for the Total field.


	(This leads me to believe that the calculate= key in \setupfield is 
working.)


 - If I try to check the calculation order of the PDF, PDF Studio 2019 
gives me the warning: "There are no fields with calculations."


(So maybe there's a magic bit that needs to get flipped somewhere?)

 - If I use PDF Studio 2019 to change the calculate attribute on the 
field Total to something else, save, and then revert the calculate 
attribute _back_ to the custom script as supplied from the .tex file and 
save, the Total field starts working as expected, and I can see the 
field in the calculation ordering.


If I can get the PDF to work in PDF Studio 2019, I can confirm that it 
also works in all of the other JS-enabled/tolerant PDF viewers I have.


# Summary

It looks like the appropriate JavaScript script is getting attached to 
the field for a calculate event, but is not being run? Or something?



Anyway, that's as far as I've gotten. Any insight or assistance is 
appreciated; I'll see if I can make more progress.


Thanks!

-Paul

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] developer not verified error

2019-11-17 Thread Keith McKay
This is the standard way to install "apps" on a mac, which have an 
unknown developer, to Apple anyway. It is a bit annoying when it happens 
especially when one has forgotten that you have to go through the 
Preferences dialog to get it to run. In my case it's an age thing.


Best Wishes

Keith McKay

On 16/11/2019 22:27, Glen Helman wrote:
There seems to be a way around this built into Catalina, however 
awkward it may be.


I tried to install lmtx on a computer running Catalina that didn’t 
have an installation and received a similar error. (There seems to be 
a quarantine applying to the text of the script and not merely the 
file because I tried creating a new document with the same text and 
received the same response, and that response referred to the download 
of the original file.)


I did find that the “general” tab under “security & privacy” in the 
system preferences had, in addition to the usual two choices, a 
reference to the downloaded script with a button reading “allow 
anyway” (or something to that effect). When I tried to run the script 
again after clicking that button, the “developer cannot  be verified” 
dialogue included “open” as a choice; and, when I clicked that, the 
script ran successfully and the installation was usable.


I then tried the install script on another computer running Cataline 
where I had installed lmtx last spring. I ran into the “developer 
cannot be verified” response again, but the same workaround allowed 
the script to run, and the installation was updated.


Glen Helman

On Nov 15, 2019, at 4:36 PM, Alan Bowen > wrote:


Though I was able to download the latest ConTeXt beta without any 
problems, my attempt to update my ConText-LMTX installation was 
blocked. The error message was


*“mtxrun” cannot be opened because the developer cannot be verified*
macOS cannot verify that this app is free from malware.
Safari downloaded this file on April 29, 2019.

I am not sure why this is happening and wonder if it would OK to copy 
mxtrun from my ConTeXt installation and replace the version in my 
ConTeXt-LMTX installation with it.


Alan
___
If your question is of interest to others as well, please add an 
entry to the Wiki!


maillist : ntg-context@ntg.nl  / 
http://www.ntg.nl/mailman/listinfo/ntg-context 


webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___



___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Text and tree side by side in a framedtext environment

2019-11-17 Thread Fabrice Couvreur
Hello,
I am looking but without success !
I tried \ starthanging [location = right] {tree} \ stophanging but that
does not work either.
Fabrice

Le sam. 16 nov. 2019 à 12:44, Fabrice Couvreur 
a écrit :

> Hello,
> I want to use a text frame to put text and a probability tree side by
> side, but it does not work.
> Thanks for your help.
> Fabrice
>
> \usemodule[tikz]
> \usetikzlibrary[trees]
>
> \definefloat
> [recipe]
> [figure]
>
>   \setupfloat
> [recipe]
> [default={right,nonumber}]
> \starttext
> \startframedtext[width=\textwidth]
>   \placerecipe{}{
> \hbox{
>   \starttikzpicture
> [level 1/.style={level distance=20mm,sibling distance=15mm},
>  level 2/.style={level distance=20mm,sibling distance=10mm}]
> \node{}[grow=right]
>   child {node{\tfxx Réglisse}
> child{node{\tfxx Réglisse}edge from parent
> node[below=2pt]{\dots}}
> child{node{\tfxx Fraise}edge from parent
> node[above=2pt]{\dots}
> } edge from parent node[below=2pt]{\dots}}
>   child {node{\tfxx Fraise}
> child{node{\tfxx Réglisse}edge from parent
> node[below=2pt]{\dots}}
> child{node{\tfxx Fraise}edge from parent
> node[above=2pt]{\dots}} edge from parent node[above=2pt]{\dots}};
>   \stoptikzpicture
> }
>   }
>   \dorecurse{2}{\input knuth}
> \stopframedtext
> \blank
>   \placerecipe{}{
> \hbox{
>   \starttikzpicture
> [level 1/.style={level distance=20mm,sibling distance=15mm},
>  level 2/.style={level distance=20mm,sibling distance=10mm}]
> \node{}[grow=right]
>   child {node{\tfxx Réglisse}
> child{node{\tfxx Réglisse}edge from parent
> node[below=2pt]{\dots}}
> child{node{\tfxx Fraise}edge from parent
> node[above=2pt]{\dots}
> } edge from parent node[below=2pt]{\dots}}
>   child {node{\tfxx Fraise}
> child{node{\tfxx Réglisse}edge from parent
> node[below=2pt]{\dots}}
> child{node{\tfxx Fraise}edge from parent
> node[above=2pt]{\dots}} edge from parent node[above=2pt]{\dots}};
>   \stoptikzpicture
> }
>   }
>   \dorecurse{2}{\input knuth}
> \stoptext
>
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___