pdfSetMouseMoveCbk
Set a callback function for mouse movement events.
void pdfSetMouseMoveCbk(PDFViewerHandle viewer,
void (*cbk)(void *data, int button, int shift,
int page, double x, double y),
void *data)
This function sets a callback which will be called when the user moves
the mouse.
The function will be called with six arguments:
data
: the value of thedata
argument that was passed topdfSetMouseMoveCbk
button
: the mouse button number - one ofpdfLeftButton
,pdfMiddleButton
, orpdfRightButton
, or 0 if no mouse button is pressedshift
: the shift/control/alt bit mask, which contains zero or more bit flags frompdfShiftKey
,pdfCtrlKey
, andpdfAltKey
page
: the current page number where the mouse cursor is locatedx, y
: the current position of the mouse cursor, in PDF coordinates
C:
/* this implements a mouse-pan feature */
int panX, panY, panSpeed;
...
panSpeed = 2
...
void mouseDownCbk(void *data, int button, int shift, int page, double x, double y) {
if (button == 1) {
pdfConvertPDFToWindowCoords2(viewer, page, x, y, &panX, &panY);
}
}
void mouseMoveCbk(void *data, int button, int shift, int page, double x, double y) {
int wx, wy;
if (button == 1) {
pdfConvertPDFToWindowCoords2(viewer, page, x, y, &wx, &wy);
pdfScrollBy(viewer, -panSpeed * (wx - panX), -panSpeed * (wy - panY));
panX = wx;
panY = wy;
}
}
....
pdfSetMouseDownCbk(viewer, &mouseDownCbk, NULL);
pdfSetMouseMoveCbk(viewer, &mouseMoveCbk, NULL);