ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Forms and JavaScript
@ 2015-04-02  7:42 Henning Hraban Ramm
  2015-04-02 15:07 ` Rik Kabel
  0 siblings, 1 reply; 7+ messages in thread
From: Henning Hraban Ramm @ 2015-04-02  7:42 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hello,

while trying to create some interactive forms using latest beta (MkIV), I found that JavaScripts are only then copied into the PDF, if there’s a \goto referencing a JS function.

According to the old widgets manual I thought I could set default values of fields calling JS functions or variables as [JS(MyFunc)], but that doesn’t work.


\starttext

\setupinteraction	[state=start]

\startJSpreamble{formtest}
% this JS code is only copied to the PDF if the \goto below is uncommented!
var d = new Date();
var df = this.getField("Datum");
var CurDate = util.printd("dd.mm.yyyy", d);
df.value = CurDate;

function toggleField(){
	var f = this.getField("Datum");
	f.display = ! f.display;
}
\stopJSpreamble

%\goto{toggle}[JS(toggleField)]
\blank

\setupfield[MMshortString][reset,horizontal][height=5mm, width=50mm, frame=off, bottomframe=on]

\definefield[Datum][line][MMshortString][][JS(CurDate)] % JS(CurDate) ends up verbatim in the field


Date: \field[Datum]


\stoptext


Greetlings, Hraban
---
http://www.fiee.net
http://wiki.contextgarden.net
https://www.cacert.org (I'm an assurer)

___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Forms and JavaScript
  2015-04-02  7:42 Forms and JavaScript Henning Hraban Ramm
@ 2015-04-02 15:07 ` Rik Kabel
  2015-04-03  5:06   ` Henning Hraban Ramm
  0 siblings, 1 reply; 7+ messages in thread
From: Rik Kabel @ 2015-04-02 15:07 UTC (permalink / raw)
  To: ntg-context

On 2015-04-02 03:42, Henning Hraban Ramm wrote:
> Hello,
>
> while trying to create some interactive forms using latest beta (MkIV), I found that JavaScripts are only then copied into the PDF, if there’s a \goto referencing a JS function.
>
> According to the old widgets manual I thought I could set default values of fields calling JS functions or variables as [JS(MyFunc)], but that doesn’t work.
>
>
> \starttext
>
> \setupinteraction	[state=start]
>
> \startJSpreamble{formtest}
> % this JS code is only copied to the PDF if the \goto below is uncommented!
> var d = new Date();
> var df = this.getField("Datum");
> var CurDate = util.printd("dd.mm.yyyy", d);
> df.value = CurDate;
>
> function toggleField(){
> 	var f = this.getField("Datum");
> 	f.display = ! f.display;
> }
> \stopJSpreamble
>
> %\goto{toggle}[JS(toggleField)]
> \blank
>
> \setupfield[MMshortString][reset,horizontal][height=5mm, width=50mm, frame=off, bottomframe=on]
>
> \definefield[Datum][line][MMshortString][][JS(CurDate)] % JS(CurDate) ends up verbatim in the field
>
>
> Date: \field[Datum]
>
>
> \stoptext
>
>
> Greetlings, Hraban
>
Greetlings Hraban,

This appears to be a pdf reader problem. On Win 8.1, Windows Reader and 
Chrome both show an editable field; Firefox and Sumatra show a 
non-editable field.

-- 
Rik
___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Forms and JavaScript
  2015-04-02 15:07 ` Rik Kabel
@ 2015-04-03  5:06   ` Henning Hraban Ramm
  2015-10-06  4:34     ` Henning Hraban Ramm
  0 siblings, 1 reply; 7+ messages in thread
From: Henning Hraban Ramm @ 2015-04-03  5:06 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 2015-04-02 um 21:07 schrieb Rik Kabel <context@rik.users.panix.com>:

> On 2015-04-02 03:42, Henning Hraban Ramm wrote:
>> while trying to create some interactive forms using latest beta (MkIV), I found that JavaScripts are only then copied into the PDF, if there’s a \goto referencing a JS function.
>> 
>> According to the old widgets manual I thought I could set default values of fields calling JS functions or variables as [JS(MyFunc)], but that doesn’t work.
> Greetlings Hraban,
> 
> This appears to be a pdf reader problem. On Win 8.1, Windows Reader and Chrome both show an editable field; Firefox and Sumatra show a non-editable field.

That’s not the problem, creating fields works great. Since JS works (probably) only in Adobe products anyway, I don’t care about other viewers. 

But JavaScript code (within JSpreamble or JScode sections) is only copied by ConTeXt into the PDF if there’s a call of \goto to one of the defined JS functions.
Additionally, calling JS functions for default values of fields doesn’t work like it did in MkII (and like it’s documented in m-widgets.pdf).

JS in PDFs is not easy to handle, but ConTeXt should at least copy my code into the PDF as it’s documented and used to work in MkII.


Greetlings, Hraban
---
http://www.fiee.net
http://wiki.contextgarden.net
https://www.cacert.org (I'm an assurer)

___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Forms and JavaScript
  2015-04-03  5:06   ` Henning Hraban Ramm
@ 2015-10-06  4:34     ` Henning Hraban Ramm
  2015-10-06 23:18       ` Hans Hagen
  0 siblings, 1 reply; 7+ messages in thread
From: Henning Hraban Ramm @ 2015-10-06  4:34 UTC (permalink / raw)
  To: mailing list for ConTeXt users

http://wiki.contextgarden.net/Widgets

Again working with widgets, this bug or feature – JavaScript code is only copied to the PDF if it’s used in a \goto – is still open.

Additionally, I found that \setupfields (plural) doesn’t work, I need to setup all formatting in each \setupfield.

I found another issue with workaround:
http://wiki.contextgarden.net/Tabulate#Itemization_or_framed_objects_inside_a_tabulation
You need to set "\tabulatesplitlinemode \plustwo" if you put widgets in a tabulation.
Is there any reason not to set this per default?


Am 2015-04-03 um 11:06 schrieb Henning Hraban Ramm <texml@fiee.net>:

> Am 2015-04-02 um 21:07 schrieb Rik Kabel <context@rik.users.panix.com>:
> 
>> On 2015-04-02 03:42, Henning Hraban Ramm wrote:
>>> while trying to create some interactive forms using latest beta (MkIV), I found that JavaScripts are only then copied into the PDF, if there’s a \goto referencing a JS function.
>>> 
>>> According to the old widgets manual I thought I could set default values of fields calling JS functions or variables as [JS(MyFunc)], but that doesn’t work.
>> Greetlings Hraban,
>> 
>> This appears to be a pdf reader problem. On Win 8.1, Windows Reader and Chrome both show an editable field; Firefox and Sumatra show a non-editable field.
> 
> That’s not the problem, creating fields works great. Since JS works (probably) only in Adobe products anyway, I don’t care about other viewers. 
> 
> But JavaScript code (within JSpreamble or JScode sections) is only copied by ConTeXt into the PDF if there’s a call of \goto to one of the defined JS functions.
> Additionally, calling JS functions for default values of fields doesn’t work like it did in MkII (and like it’s documented in m-widgets.pdf).
> 
> JS in PDFs is not easy to handle, but ConTeXt should at least copy my code into the PDF as it’s documented and used to work in MkII.
> 
> 
> Greetlings, Hraban
> ---
> http://www.fiee.net
> http://wiki.contextgarden.net
> https://www.cacert.org (I'm an assurer)

___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Forms and JavaScript
  2015-10-06  4:34     ` Henning Hraban Ramm
@ 2015-10-06 23:18       ` Hans Hagen
  2015-10-07  9:56         ` Henning Hraban Ramm
  0 siblings, 1 reply; 7+ messages in thread
From: Hans Hagen @ 2015-10-06 23:18 UTC (permalink / raw)
  To: ntg-context

On 10/6/2015 6:34 AM, Henning Hraban Ramm wrote:
> http://wiki.contextgarden.net/Widgets
>
> Again working with widgets, this bug or feature – JavaScript code is only copied to the PDF if it’s used in a \goto – is still open.

feature but you can say

\startJSpreamble FOO used now
...

> Additionally, I found that \setupfields (plural) doesn’t work, I need to setup all formatting in each \setupfield.

fields have always be special as there can be thousands of fields their 
settings are saved in a special way (in order not to run out of memory / 
hash space then) ... kind of mkii compatible

> I found another issue with workaround:
> http://wiki.contextgarden.net/Tabulate#Itemization_or_framed_objects_inside_a_tabulation
> You need to set "\tabulatesplitlinemode \plustwo" if you put widgets in a tabulation.
> Is there any reason not to set this per default?

it would break other things

it's hard to predict what goes in cells so some heuristics works better 
when explicitly told

Hans

> Am 2015-04-03 um 11:06 schrieb Henning Hraban Ramm <texml@fiee.net>:
>
>> Am 2015-04-02 um 21:07 schrieb Rik Kabel <context@rik.users.panix.com>:
>>
>>> On 2015-04-02 03:42, Henning Hraban Ramm wrote:
>>>> while trying to create some interactive forms using latest beta (MkIV), I found that JavaScripts are only then copied into the PDF, if there’s a \goto referencing a JS function.
>>>>
>>>> According to the old widgets manual I thought I could set default values of fields calling JS functions or variables as [JS(MyFunc)], but that doesn’t work.
>>> Greetlings Hraban,
>>>
>>> This appears to be a pdf reader problem. On Win 8.1, Windows Reader and Chrome both show an editable field; Firefox and Sumatra show a non-editable field.
>>
>> That’s not the problem, creating fields works great. Since JS works (probably) only in Adobe products anyway, I don’t care about other viewers.
>>
>> But JavaScript code (within JSpreamble or JScode sections) is only copied by ConTeXt into the PDF if there’s a call of \goto to one of the defined JS functions.
>> Additionally, calling JS functions for default values of fields doesn’t work like it did in MkII (and like it’s documented in m-widgets.pdf).
>>
>> JS in PDFs is not easy to handle, but ConTeXt should at least copy my code into the PDF as it’s documented and used to work in MkII.
>>
>>
>> Greetlings, Hraban
>> ---
>> http://www.fiee.net
>> http://wiki.contextgarden.net
>> https://www.cacert.org (I'm an assurer)
>
> ___________________________________________________________________________________
> 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://tex.aanhet.net
> archive  : http://foundry.supelec.fr/projects/contextrev/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________
>


-- 

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Forms and JavaScript
  2015-10-06 23:18       ` Hans Hagen
@ 2015-10-07  9:56         ` Henning Hraban Ramm
  2015-10-07 11:13           ` Hans Hagen
  0 siblings, 1 reply; 7+ messages in thread
From: Henning Hraban Ramm @ 2015-10-07  9:56 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Am 2015-10-07 um 05:18 schrieb Hans Hagen <pragma@wxs.nl>:

> On 10/6/2015 6:34 AM, Henning Hraban Ramm wrote:
>> Again working with widgets, this bug or feature – JavaScript code is only copied to the PDF if it’s used in a \goto – is still open.
> 
> feature but you can say
> 
> \startJSpreamble FOO used now
> …

Thank you, that’s great.

>> Additionally, I found that \setupfields (plural) doesn’t work, I need to setup all formatting in each \setupfield.
> 
> fields have always be special as there can be thousands of fields their settings are saved in a special way (in order not to run out of memory / hash space then) ... kind of mkii compatible

Hm, but it worked in MkII? (I guess, at least it’s documented that way.)

>> I found another issue with workaround:
>> http://wiki.contextgarden.net/Tabulate#Itemization_or_framed_objects_inside_a_tabulation
>> You need to set "\tabulatesplitlinemode \plustwo" if you put widgets in a tabulation.
>> Is there any reason not to set this per default?
> 
> it would break other things
> 
> it's hard to predict what goes in cells so some heuristics works better when explicitly told

Ok, then I’d like to understand what the commands do – I’m working on a set of forms, where tabulations break the one or other way, depending on their content. Perhaps I should just use any tables, but can you enlighten me about that splitlinemode?


Greetlings, Hraban
---
http://www.fiee.net
http://wiki.contextgarden.net
https://www.cacert.org (I'm an assurer)

___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Forms and JavaScript
  2015-10-07  9:56         ` Henning Hraban Ramm
@ 2015-10-07 11:13           ` Hans Hagen
  0 siblings, 0 replies; 7+ messages in thread
From: Hans Hagen @ 2015-10-07 11:13 UTC (permalink / raw)
  To: ntg-context

On 10/7/2015 11:56 AM, Henning Hraban Ramm wrote:
> Am 2015-10-07 um 05:18 schrieb Hans Hagen <pragma@wxs.nl>:
>
>> On 10/6/2015 6:34 AM, Henning Hraban Ramm wrote:
>>> Again working with widgets, this bug or feature – JavaScript code is only copied to the PDF if it’s used in a \goto – is still open.
>>
>> feature but you can say
>>
>> \startJSpreamble FOO used now
>> …
>
> Thank you, that’s great.
>
>>> Additionally, I found that \setupfields (plural) doesn’t work, I need to setup all formatting in each \setupfield.
>>
>> fields have always be special as there can be thousands of fields their settings are saved in a special way (in order not to run out of memory / hash space then) ... kind of mkii compatible
>
> Hm, but it worked in MkII? (I guess, at least it’s documented that way.)
>
>>> I found another issue with workaround:
>>> http://wiki.contextgarden.net/Tabulate#Itemization_or_framed_objects_inside_a_tabulation
>>> You need to set "\tabulatesplitlinemode \plustwo" if you put widgets in a tabulation.
>>> Is there any reason not to set this per default?
>>
>> it would break other things
>>
>> it's hard to predict what goes in cells so some heuristics works better when explicitly told
>
> Ok, then I’d like to understand what the commands do – I’m working on a set of forms, where tabulations break the one or other way, depending on their content. Perhaps I should just use any tables, but can you enlighten me about that splitlinemode?

p entries are paragraphs that get split in lines so weird content can 
give weird splits (esp when they are not lines of text)

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-10-07 11:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-02  7:42 Forms and JavaScript Henning Hraban Ramm
2015-04-02 15:07 ` Rik Kabel
2015-04-03  5:06   ` Henning Hraban Ramm
2015-10-06  4:34     ` Henning Hraban Ramm
2015-10-06 23:18       ` Hans Hagen
2015-10-07  9:56         ` Henning Hraban Ramm
2015-10-07 11:13           ` Hans Hagen

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).