1

I am trying to implement code for different events on a shape which is dragged on to the paper element from stencil. pointerup event triggers a halo with options around the element. Double click event triggers some modal window and right click event triggers a custom context menu with click actions. How can i differentiate different events in Rappid like leftclick, rightclick, clicking on mouse wheel. I have code as below.

this.paper.on({
        'element:pointerup': onElementClick,
         //something like contextmenu
        //'element:contextmenu': onElementRightClick,
    });

This is a workaround i got from rappid for click and doubleclick.It is working but i am looking for rightclick functionality too. please, help.

paper.on({
    'element:pointerdown': onElementClick
});
var clickTimerId;
function onElementClick(view) {
    if (clickTimerId) {
        // double click
        window.clearTimeout(clickTimerId);
        clickTimerId = null;
        onElementDblClick(view);
    } else {
        // single click
        clickTimerId = window.setTimeout(click, 200);
    }
    function click() {
        clickTimerId = null;
        // open halo and inspector here
    }
}
function onElementDblClick(view) {
    // open the modal window here
}
priya
  • 21
  • 5

1 Answers1

1

cell:contextmenu - triggered when the user right-clicks a cell in the paper.

from the jointjs api documentation so please try the below

paper.on({
    'element:contextmenu': onElementRightClick
});

function onElementRightClick(view) {

}