ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <j.hagen@xs4all.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>,
	Henning Hraban Ramm <texml@fiee.net>
Subject: Re: Widgets: Any good examples for developing JS-enabled PDFs that calculate?
Date: Mon, 18 Nov 2019 19:56:14 +0100	[thread overview]
Message-ID: <9cc6c8d5-0861-f818-a70f-9d0534955da5@xs4all.nl> (raw)
In-Reply-To: <29EB1078-FC73-486E-848F-5D22421B3BA4@fiee.net>

On 11/18/2019 4:15 PM, Henning Hraban Ramm wrote:
> Hi,
> I didn’t check your example, but I remember that JScode did only work if there’s also a JSpreamble.
> Also the "used now" keyword (see Hans’ message) is essential.

i don't think so, the code is in the file and one can see that arobat 
sees it too but using a preamble and functions is more efficienty 
(reuse) and easier to trace

the problem with calculate is that there are also settings related to it 
(plus some built-in addition stuff, at least that's what i see in the 
viewer preferences and such, which is likely to interfere)

(and calculate doens't seem to be called at all)


> HTH. Sorry, no time for further investigation.
> 
> Hraban
> 
>> Am 2019-11-17 um 21:13 schrieb Paul Mazaitis <pm39@andrew.cmu.edu>:
>>
>>
>> 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  ---
> 
> ___________________________________________________________________________________
> 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
> ___________________________________________________________________________________
> 


-- 

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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
___________________________________________________________________________________

  reply	other threads:[~2019-11-18 18:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-07 19:28 [Widgets] " Paul Mazaitis
2019-11-13 15:26 ` Pablo Rodriguez
2019-11-17 20:13   ` Widgets: " Paul Mazaitis
2019-11-18  8:48     ` Hans Hagen
2019-11-19 22:47       ` Paul Mazaitis
2019-11-18 15:15     ` Henning Hraban Ramm
2019-11-18 18:56       ` Hans Hagen [this message]
2019-11-19 13:59         ` Paul Mazaitis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9cc6c8d5-0861-f818-a70f-9d0534955da5@xs4all.nl \
    --to=j.hagen@xs4all.nl \
    --cc=ntg-context@ntg.nl \
    --cc=texml@fiee.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).