Confirm before deleting annotation

59 views
Skip to first unread message

Matt Parizeau

unread,
Jun 25, 2014, 3:15:10 PM6/25/14
to pdfnet-w...@googlegroups.com
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);
           
}
       
}
   
};
});
Reply all
Reply to author
Forward
0 new messages