Q:
Would it be possible to prevent a doubleclick on an annotation to bubble/propagate to the DOM? We want to use the doubleclick on a page to zoom to 200%. So if we click outside an annotation we want the event to zoom, and on an annotation we want it to edit the annotation. Is this possible?
A:
You would want to override the base tool's double click method. Inside there you'll have to check if an annotation is being clicked on and if so then stop the propagation of the event. You can do this with code like the following:
var annotManager = docViewer.GetAnnotationManager();
var oldDoubleClick = window.Tools.Tool.prototype.mouseDoubleClick;
window.Tools.Tool.prototype.mouseDoubleClick = function(e) {
oldDoubleClick.call(this, e);
var pageCoordinate = this.pageCoordinates[0];
var annotations = annotManager.GetAnnotationsList();
for (var i = 0; i < annotations.length; i++) {
var annot = annotations[i];
if (annot.GetPageNumber() - 1 === pageCoordinate.pageIndex) {
var rect = {
x1: annot.GetLeft(),
y1: annot.GetTop(),
x2: annot.GetRight(),
y2: annot.GetBottom()
};
if (pageCoordinate.x >= rect.x1 && pageCoordinate.x <= rect.x2 && pageCoordinate.y >= rect.y1 && pageCoordinate.y <= rect.y2) {
e.stopImmediatePropagation();
break;
}
}
}
};
Note that this is the code necessary for WebViewer 1.6. With WebViewer 1.7 you'll need to modify the code slightly for it to work with the new annotations and annotation selection.
Matt Parizeau
Software Developer
PDFTron Systems Inc.