How to add event listener

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
betterRunner
User
Posts: 7
Joined: Fri Nov 23, 2018 8:44 am

How to add event listener

Post by betterRunner »

Hi all,

I am sorry but I am a newer of PDF-XChange Editor SDK, and I think I can not figure out where to add the event listener in the fulldemo of Editor SDK in c#.

To be specific, I know that for example the event of adding annotation can be looked up in https://sdkhelp.pdf-xchange.com/view/PXV:PXV_Events, but I don't know how to add this into the code of "fulldemo", an example about how to add it in the code would be greatfu.

Thank you very much!
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How to add event listener

Post by Sasha - Tracker Dev Team »

Hello betterRunner,

There is an event listener in the FullDemo already - search for the pdfCtl_OnEvent method. To add the needed events, first add them into the IDS enum and then you can use the if statement inside of the pdfCtl_OnEvent to catch them.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
betterRunner
User
Posts: 7
Joined: Fri Nov 23, 2018 8:44 am

Re: How to add event listener

Post by betterRunner »

Hello Alex,

Thanks for the help.

The pdfCtl_OnEvent does receive a lot of events like scrolling the page and so on. But I found it does not trigger when adding one highlight annotation, where the e.annots.inserted should be called.

So why is that, actually I can even see the code (commented) in pdfCtl_OnEvent

Code: Select all

PDFXEdit.IPXV_AnnotsEvent annotsEvent = (PDFXEdit.IPXV_AnnotsEvent)e.pEvent; 
,
but the event just has not triggered.

Thanks a lot!
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How to add event listener

Post by Sasha - Tracker Dev Team »

Hello betterRunner,

Like I said before, to listen to the needed event you will need to add it by using the EnableEventListening method of the IPXV_Control. In the FullDemo application, it is being done via the RegisterEvents method that reads the contents of the IDS enum and launches the EnableEventListening method for each of them.
Basically, if you add the e_annots_inserted element to the enum, the OnEvent will handle that event, though I advise adding the if statement before the commented code so that you would read the correct event.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
betterRunner
User
Posts: 7
Joined: Fri Nov 23, 2018 8:44 am

Re: How to add event listener

Post by betterRunner »

Hello Alex,

Thanks for your help, it works after adding e_annots_inserted in enum as what you said.

Thanks.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How to add event listener

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply