Prevent deselection on pressing RMB

Tags: #<Tag:0x00007efc621251f0>

Hello! Let’s say I’m selecting a row on pressing LMB (left mouse button). Then I inadvertently press RMB (right mouse button) on a random cell. As a result, the last row selection would be deselected. Is it possible to prevent deselection?

I’ve already understood how to prevent cell selection on pressing RMB, I did it like so:

afterOnCellMouseDown: (event, coords, td) => {

        if(event.button == 2){

          this.myInstance.deselectCell();

          event.stopImmediatePropagation();

          event.preventDefault();

        }
}

There’s also

document.addEventListener(‘contextmenu’, event => event.preventDefault());

if you want to hide browser context menu.

1 Like

There’s still an issue: I want a selection caused by LMB to not to be deselected, if I press RMB by accident.

I guess that it won’t be possible via API, that would require a change in the source code. As a workaround you can use selectCell() (add the selection once again) if event.button == 2 is pressed.