Q:
I was wondering if it’s possible to prevent the deletion of annotations on pressing the delete key. I need to raise a dialog to confirm deletion rather than deleting the annotation directly.
A:
You can use the following code to insert your own confirmation dialog:
$(document).on('viewerLoaded', function() {
var deleteKey = 46;
var originalKeyDown = window.Tools.AnnotationEditTool.prototype.keyDown;
window.Tools.AnnotationEditTool.prototype.keyDown = function(e) {
if (e.which === deleteKey && !window.utils.isEditableElement($(e.target))) {
if (myConfirmationFunction()) {
originalKeyDown.apply(this, arguments);
}
}
};
});