Ag-grid:使用 enableCellTextSelection 并选择文本时如何禁用单元格单击事件?

Ag-grid: How disable cell click event when enableCellTextSelection is used and text is selected?

使用 ag-Grid Community 和 Angular,我设置 [enableCellTextSelection]="true" 以启用单元格文本选择以方便复制粘贴,但我发现 cellClicked 事件仍然在文本时触发被选中并释放鼠标按钮(在同一个单元格中单击、拖动和释放鼠标)。

有没有办法检测在 cellClicked 事件中选择了文本并“取消/快速退出”它?

我寻找一种方法来区分鼠标按下和鼠标弹起坐标,但找不到任何东西...

谢谢。


正在使用的版本

这里有一些您可以使用的解决方法。使用 window.getSelection() 获取用户选择的文本。由此,您可以确定是否已选择文本。

将您的 cellClicked 回调函数更改为:

cellClicked(event)
    {
      if (window.getSelection().type !== 'Range')
      {
        //text has not been selected, the cell has been clicked
        console.log('cellClicked');
      }
    }

Demo