[javascript FR] Improved event model

Please post any ideas or requests for new features here for the End User Version of PDF-XChange (printer Drivers)

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange, Tracker - Clarion Support, John - Tracker Supp, Support Staff, moderators

Mathew
User
Posts: 736
Joined: Thu Jun 19, 2014 7:30 pm

[javascript FR] Improved event model

Post by Mathew »

This request is for something more similar to addEventListener() and removeEventListener() which add and remove events without overwriting previously defined events, and only in the current session of the document (ie they are not saved with the document.)

Currently, one can assign events (actions), but they have numerous problems:
  • Added events are saved as part of the document. It makes sense if one is trying to make a document that has dynamic content; but looking at it from the perspective of a tool that is used on any document, the current methods are very clumsy and ill-suited: I end up adding even more events to try to "clean up" the previously added events in a bit of a dog-chasing-his-tail dance.
  • Any previously assigned events get clobbered. There is no way for javascript to even know if an event is already defined on an element, let alone a way to know what that function is, so there's no way to try to preserve it. This means that if two tools are trying to add events, one will overwrite the other, and probably prevent either tool working properly. Or worse, the tool will overwrite a script that is an important part of the document.
  • Events are only defined in very limited subset of elements. There are no events for annotations, no 'scroll' event for pages, or mouse click on anything except forms, for instance. This results in performance degrading background polling (ie intervals) looking for these changes.
  • There is no way to define custom events. The closest I can think of this is adding watches to global variables.
It is understandable why the current addAction() overwrites events: The thinking was on document creation so the script would presumably be attempting to create form or open/close/save events as part of the document. That Is why I'm thinking completely different methods are needed. As with browsers, I would expect that addEventListener would not overwrite or be affected by addAction(). Both events would happen, one after the other. But the latter method would be saved with the document.
Last edited by Mathew on Wed Sep 03, 2025 5:35 pm, edited 1 time in total.
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 12227
Joined: Wed Jan 03, 2018 6:52 pm

Re: [javascript FR] Improved event model

Post by Daniel - PDF-XChange »

Hello, Mathew

Thank you for the suggestions/request. I have passed this along to the Dev team and asked them to review it here. We will keep you posted if anything comes of it.

[update]
It has been confirmed that while this is something we hope to work on in the future, it is unfortunately not something we can prioritize at the moment and will likely not be added anytime soon...

Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com