How to make the mouse pointer to be 'sw-resize' when hovering over the custom control handle

53 views
Skip to first unread message

Hentry Martin

unread,
Nov 7, 2016, 1:45:04 PM11/7/16
to PDFTron WebViewer
Hi,
I have written an custom control handle for the stamp annotation. On hovering over the custom control handle, I want to make the cursor pointer to be 'sw-resize'. How can I achieve it??

Thanks,
Hentry.

Matt Parizeau

unread,
Nov 8, 2016, 9:23:45 PM11/8/16
to PDFTron WebViewer
Hi Hentry,

You could use code like the following to change the cursor when hovering over any control handle:

$(document).on('viewerLoaded', function() {
 
var docViewer = readerControl.docViewer;

  docViewer
.on('mouseMove', function(e, nativeEvent) {
   
var tool = new window.Tools.Tool(docViewer);
    tool
.mouseLeftDown(nativeEvent);
   
var pageCoordinate = tool.pageCoordinates[0];
   
if (pageCoordinate) {
     
var am = docViewer.getAnnotationManager();

     
var selectedAnnotations = am.getSelectedAnnotations();
     
for (var s = 0; s < selectedAnnotations.length; s++) {
       
var selectedAnnotation = selectedAnnotations[s];
       
var selectionModel = new selectedAnnotation.selectionModel(selectedAnnotation, am.canModify(selectedAnnotation));
       
var controlPoint = selectionModel.testControlHandles(selectedAnnotation, docViewer.getPageZoom(selectedAnnotation.PageNumber - 1), pageCoordinate.x, pageCoordinate.y);
       
if (controlPoint) {
          docViewer
.el.css('cursor', 'sw-resize');
         
return;
       
}
     
}
   
}
    docViewer
.el.css('cursor', 'pointer');
 
});
});

Matt Parizeau
Software Developer
PDFTron Systems Inc.
Reply all
Reply to author
Forward
0 new messages