Search code examples
javascriptevent-handlingspreadjs

How to intercept a right-click on a cell in spreadJS


I'm trying to intercept a right-click event with spreadJS, sadly the event doesn't exist on the list : SpreadJS Events Type, only left click can be intercepted.

Is there any way to intercept a right-click on a cell?

I know we can customize the context menu but I need to intercept the right-click because in my case I have disabled the context menu.


Solution

  • This is able to be accomplished by adding an event listener like so:

    spread.options.allowContextMenu = false;
    spread.getHost().addEventListener("contextmenu", function (e) {
        // your code;
        e.preventDefault();
        return false;
    });