Is it possible to get to know about annotation selection when pttoolmanager is currently in CreateTool Mode?

32 views
Skip to first unread message

Vignesh Kumar

unread,
Sep 11, 2019, 4:36:48 PM9/11/19
to PDFTron PDFNet SDK

I am developing a Xamarin.Forms app and I want to lock pttoolmanager to specific tool type until user explicitly choose to exit out ( to PTPanTool).

I did achieve that behaviour with the line ‘toolManager.Tool.BackToPanToolAfterUse = false;’

But by doing so the PTToolmanager is not able to see that an annotation got tapped when user tap on top of the existing annotation


Is it possible to have an api to inform integrators about an annotation being tapped so that they can make use of it?

Or is there any other way it is possible and I am missing? 

Vignesh Kumar

unread,
Sep 11, 2019, 4:36:55 PM9/11/19
to PDFTron PDFNet SDK

Shakthi Wijeratne

unread,
Sep 16, 2019, 2:48:00 PM9/16/19
to PDFTron PDFNet SDK
Hello,

When locking the tool manager to a specific tool type and using BackToPanToolAfterUse = false, the current tool class is responsible for handling taps and touches. Some tools, like the text highlight create tool, will select existing text highlight annotations when tapped but not other annotation types.

If you'd like to select arbitrary annotations while in any tool, you can implement the PTToolManager's HandleTap method, which is called first before any tool can handle the tap:
public override bool HandleTap(PTToolManager toolManager, UITapGestureRecognizer gestureRecognizer)
{
   
CGPoint location = gestureRecognizer.LocationInView(this.PdfViewCtrl);
    pdftronprivate
.PTAnnot _annot = this.PdfViewCtrl.GetAnnotationAt((int)location.X, (int)location.Y, 1, 1);
   
Annot annot = TypeConvertHelper.ConvAnnotToManaged(_annot);
   
if (annot.IsValid())
   
{
       
return toolManager.SelectAnnotation(_annot, (nuint)this.PdfViewCtrl.GetCurrentPage());
   
}
   
return false;
}

Vignesh Kumar

unread,
Sep 26, 2019, 2:20:35 PM9/26/19
to PDFTron PDFNet SDK
Thanks for the response it really helped us to implement the tool lock mode. 
Reply all
Reply to author
Forward
0 new messages