How to react to annotation selection on Control

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.
khho
User
Posts: 34
Joined: Fri Mar 11, 2022 11:02 am

How to react to annotation selection on Control

Post by khho »

Hello Support,
I want to react to the selection of an annotation in the control.

How can I do this?
I don't find an a suitable event to react to in OnEvent method (I only found e.stampSelected).

Maybe there is a way to do this writing a EventListener? On what? What would be the UIX_EventCode?

Kind regards
User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 2353
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: How to react to annotation selection on Control

Post by Vasyl-Tracker Dev Team »

You may try to handle the e.docSelection.changed. Then:

Code: Select all

int id_e_docSelection_changed = Str2ID("e.docSelection.changed");
int id_selection_annots = Str2ID("selection.annots");
....
OnEvent(eventID, event, from)
{
      if (eventID == id_e_docSelection_changed)
      {
           selEvent = (IPXV_DocSelChangedEvent)event;
           if (selEvent != null)
           {
                 if (selEvent.Selection[id_selection_annots]) 
                 {
                      doc = (IPXV_Document)from;
                      if (doc != null)
                      {
                           annotSel = (IPXV_AnnotSelection)doc.GetSel(id_selection_annots);
                           ...     
                      }
                 }
           }
      }
}
Vasyl Yaremyn
Tracker Software Products
Project Developer

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
khho
User
Posts: 34
Joined: Fri Mar 11, 2022 11:02 am

Re: How to react to annotation selection on Control

Post by khho »

Thank you for this answer.
Unfortunately IPXV_DocSelChangedEvent does not exist at design time in the Interop.PDFXEdit.dll that I use (though it is there at runtime) and to change version might lead to other problems

Is there an alternative way?
User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 2353
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: How to react to annotation selection on Control

Post by Vasyl-Tracker Dev Team »

I checked this, for example, in our FullDemo app, and it seems everything looks good with that. Just used the PDFXEdit.IPXV_DocSelChangedEvent type there...

But anyway, at the moment, you may simplify the code above by removing using that type. It should work without it too:

Code: Select all

if (eventID == id_e_docSelection_changed)
{                      
       doc = (IPXV_Document)from;
       if (doc != null)
       {
             annotSel = (IPXV_AnnotSelection)doc.GetSel(id_selection_annots);
             ...     
       }
}
HTH.
Vasyl Yaremyn
Tracker Software Products
Project Developer

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
khho
User
Posts: 34
Joined: Fri Mar 11, 2022 11:02 am

Re: How to react to annotation selection on Control

Post by khho »

(Late) thanks for this! :)
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17960
Joined: Mon Jan 12, 2009 8:07 am
Location: London

How to react to annotation selection on Control

Post by Tracker Supp-Stefan »

:)