Skip to content

How to catch pointer position of the mouse when pressing the right button? #2685

Answered by kumilingus
rmnsfx asked this question in Q&A
Discussion options

You must be logged in to vote

For now please use something similar to this:

paper.on('blank:contextmenu', (evt) => {

    joint.highlighters.mask.removeAll(paper, 'my-highlighter');

    const lasso = V('rect', {
        'fill': 'red',
        'fill-opacity': 0.2,
        'stroke': 'red'
    });
    lasso.appendTo(paper.viewport);

    const { x, y } = paper.clientToLocalPoint(evt.clientX, evt.clientY);
    const startX = x;
    const startY = y;

    function getBBox(evt) {
        const { x, y } = paper.clientToLocalPoint(evt.clientX, evt.clientY);
        return new g.Rect(startX, startY, (x - startX) || 1, (y - startY) || 1).normalize();
    }

    function onPointermove(evt) {
        lasso.attr(getBBox(evt).norm…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@rmnsfx
Comment options

@kumilingus
Comment options

@rmnsfx
Comment options

@kumilingus
Comment options

Answer selected by rmnsfx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants