0

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.

Ganbin
  • 2,004
  • 2
  • 12
  • 19

1 Answers1

2

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;
});
GrapeCity Team
  • 837
  • 1
  • 5
  • 8
  • Thanks for the answer. This lead me to another question, on can I know the cell (row and column) on which I have done a right-click? – Ganbin Jul 14 '20 at 09:49
  • I was abale to find a solution thanks to the https://www.grapecity.com/forums/spread-sheets/conditionally-displaying-d comment. You must downlaod the zip example to get the `getCumulativeOffset`function and then with the `spread.hitTest` , you can know in which cell you actually are. Tricky but it work at the end. – Ganbin Jul 14 '20 at 14:18