Using ag-Grid Community and Angular, I set [enableCellTextSelection]="true"
to enable cell text selection to facilitate copy-paste, but I found that the cellClicked
event still fires when text is selected and the mouse button is released (i.e. the mouse is clicked, dragged and released in the same cell).
Is there a way to detect that text is selected in the cellClicked
event and "cancel / quick exit" it?
I looked for a way to distinguish between the mouse down and mouse up coordinates but couldn't find anything...
Thanks.
Version in use
Here's a little workaround you can use. Use window.getSelection()
to get the text selected by the user. From this, you can determine if text has been selected or not.
Change your cellClicked
callback function to this:
cellClicked(event)
{
if (window.getSelection().type !== 'Range')
{
//text has not been selected, the cell has been clicked
console.log('cellClicked');
}
}