I want to create an annotation of a fixed size with a single click instead of requiring a click/drag to set the width and height. Is this possible?
The following code is based on the custom diamond sample and should be able to be adjusted for other types of annotations, including custom ones.
var CustomDiamondCreateTool = function(docViewer) {
Tools.GenericAnnotationCreateTool.call(this, docViewer, CustomDiamondAnnotation);
};
CustomDiamondCreateTool.prototype = new Tools.GenericAnnotationCreateTool();
CustomDiamondCreateTool.prototype.mouseLeftDown = function() {
Tools.AnnotationSelectTool.prototype.mouseLeftDown.apply(this, arguments);
};
CustomDiamondCreateTool.prototype.mouseMove = function() {
Tools.AnnotationSelectTool.prototype.mouseMove.apply(this, arguments);
};
CustomDiamondCreateTool.prototype.mouseLeftUp = function(e) {
var annotation;
Tools.GenericAnnotationCreateTool.prototype.mouseLeftDown.call(this, e);
if (this.annotation) {
this.annotation.Width = 100;
this.annotation.Height = 100;
annotation = this.annotation;
}
Tools.GenericAnnotationCreateTool.prototype.mouseLeftUp.call(this, e);
if (annotation) {
readerControl.docViewer.getAnnotationManager().redrawAnnotation(annotation);
}
};