PDFViewWPD annotation onClick action ?

Hi,

I need a custom method to run whenever a user clicks on an annotation (I'm using Highlights). I need to also have a handle on the clicked annotation object as well. I'm not seeing how to do in the API/Examples.

Thanks,

Barry

FYI…I’m using .Net/C# and the PDFViewWPF viewer !

The user needs to be able to create highlights (annotations) at will, and get a handle on an existing highlight (annotation) when the user clicks on it.

Thanks…Barry

Please check out my other reply for more details, but everything you want to do is in the PDFViewWPFTools code. Either modify an existing tool, or add your own new one based on an existing one.

This how I ended up doing…

i had for forage ahead with alot of trial and error, due to the slow answer rate in this Group. I needed the method to trigger on a single click, not a double click…

The meat of it was gleaned from: https://groups.google.com/forum/#!searchin/pdfnet-sdk/rect$20from$20mouse/pdfnet-sdk/kTr9FzbGiBE/Uu1cJdc8CDoJ

private PDFViewWPF _pdfViewer;

private bool _userClick = false;

private Annot _annotFromClick;

private System.Windows.Point _userClickPoint;

.
.
.

private void PdfViewer_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
_userClick = false;
}

private void PdfViewer_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
_userClick = true;
_userClickPoint = e.GetPosition(_pdfViewer); //X and Y of mouse position within viewer
}

private void PdfViewer_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{

Page currentPage;

if (_userClick)
{
double x = _userClickPoint.X;
double y = _userClickPoint.Y;

_pdfViewer.ConvScreenPtToPagePt(ref x, ref y, _pdfViewer.CurrentPageNumber);

currentPage = _pdfDocument.GetPage(_pdfViewer.CurrentPageNumber);

try
{
int annot_num = currentPage.GetNumAnnots();

for (int i = 0; i < annot_num; ++i)
{
Annot parsingAnnot = currentPage.GetAnnot(i);
if (parsingAnnot.IsValid() == false || parsingAnnot.GetType() !=
Annot.Type.e_Highlight) continue;
Rect box = parsingAnnot.GetRect();

if (box.Contains(x, y))
{

//WE HAVE A MATCHING ANNOTATION
_annotFromClick = new Annot(parsingAnnot);

//FROM THIS POINT I CAN RUN MY BUSINESS LOGIC WITH A HANDLE ON THE ANNOTATION THAT WAS CLICKED ON

}
}

}
catch { //no annots on page
}

}