I've had a look. I'm trying to create a fixed-size annotation. Using that triangle example, I've got a creation tool like so:
var TriangleCreateTool = function(docViewer) {
Tools.GenericAnnotationCreateTool.call(this, docViewer, TriangleAnnotation);
};
TriangleCreateTool.prototype = new Tools.GenericAnnotationCreateTool();
TriangleCreateTool.prototype.mouseLeftDown = function(e) {
Tools.GenericAnnotationCreateTool.prototype.mouseLeftDown.call(this, e);
if (this.annotation) {
this.annotation.X = this.annotation.X - this.annotation.Width/2;
this.annotation.Y = this.annotation.Y - this.annotation.Height/2;
// update the annotation appearance
this.docViewer.getAnnotationManager().redrawAnnotation(this.annotation);
}
}
TriangleCreateTool.prototype.mouseMove = function(e) {}
TriangleCreateTool.prototype.mouseLeftUp = function(e) {
Tools.GenericAnnotationCreateTool.prototype.mouseLeftUp.call(this, e);
}
But this creates an annotation on mousedown. I want behaviour like other tools - click on an existing annotation and that is selected, otherwise create a new one.
If I move the if (this.annotation) {} block into the beginning of mouseLeftUp(), then the annotation where the mouse is gets selected, but a new annotation is created as well.
How do I get the behaviour:
If existing annotation, of any type, is clicked on, select that.
Otherwise, create a new TriangleAnnotation.
Thanks