pdfSetMouseUpWinCbk
Set a callback function for mouse button-up events with window coordinates.
void pdfSetMouseUpWinCbk(PDFViewerHandle viewer,
void (*cbk)(void *data, int button, int shift,
int winX, int winY),
void *data)
This function sets a callback which will be called when the user
releases a mouse button.
The function will be called with five arguments:
data
: the value of thedata
argument that was passed topdfSetMouseUpCbk
button
: the mouse button number - one ofpdfLeftButton
,pdfMiddleButton
, orpdfRightButton
shift
: the shift/control/alt bit mask, which contains zero or more bit flags frompdfShiftKey
,pdfCtrlKey
, andpdfAltKey
winX, winY
: the position where the mouse button was clicked, in window coordinates
pdfConvertWindowToPDFCoords2
.
This callback is similar to pdfSetMouseUpCbk
, except that (a) it
is called with window coordinates instead of PDF coordinates, and (b)
it will be called even if the mouse is clicked outside of a PDF page.
IMPORTANT: In order to receive pdfSetMouseMoveWinCbk
and
pdfSetMouseUpWinCbk
callbacks when the mouse is outside
the XpdfViewer window (not just outside the PDF pages), you must
call SetCapture
in the pdfSetMouseDownWinCbk
callback. See the example below.
C:
void mouseDownWinCbk(void *data, int button, int shift,
int winX, int winY) {
Context *myContext = (Context *)data;
int pg;
double x, y;
pdfConvertWindowToPDFCoords2(viewer, winX, winY, &pg, &x, &y);
/* ... use pg, x, y ... */
/* capture the mouse so we receive Move and Up events outside the window */
SetCapture(pdfGetWindowHandle(viewer));
}
void mouseUpWinCbk(void *data, int button, int shift,
int winX, int winY) {
Context *myContext = (Context *)data;
int pg;
double x, y;
/* release the capture that was initiated in the Down callback */
ReleaseCapture();
pdfConvertWindowToPDFCoords2(viewer, winX, winY, &pg, &x, &y);
/* ... use pg, x, y ... */
}
void mouseMoveWinCbk(void *data, int button, int shift,
int winX, int winY) {
Context *myContext = (Context *)data;
int pg;
double x, y;
pdfConvertWindowToPDFCoords2(viewer, winX, winY, &pg, &x, &y);
/* ... use pg, x, y ... */
}
....
pdfSetMouseDownWinCbk(viewer, &mouseDownWinCbk, &myContext);
pdfSetMouseUpWinCbk(viewer, &mouseDownWinCbk, &myContext);
pdfSetMouseMoveWinCbk(viewer, &mouseDownWinCbk, &myContext);