双击图片能获取到事件,旁边的两个单元格也能获取到。没找到问题在哪里。
dblclickAction();
}, 1000);
}) const dblclickAction = ()=>{
let Designer = GC.Spread.Sheets.Designer.findControl('designer-container');
let spread = Designer.getWorkbook()
document.getElementById('designer-container').addEventListener('dblclick', function (e) {
let _x = e.pageX - 28
let offsetLeft = 68;
if (!Designer.getData("isRibbonCollapse")) {
offsetLeft = 174
}
let _y = e.pageY - offsetLeft;
console.log("e.pageX",_x,",this.offsetTop",_y)
let result = spread.hitTest(_x, _y)
var {row, col} = getHitAreaName(result);
let sheet = spread.getActiveSheet();
// let sheet = spread.getSheet(1);
console.log(sheet.shapes.all(), '-----所有值---', row, col)
for (let i = 0; i < sheet.shapes.all().length; i++) {
if (sheet.shapes.all() instanceof GC.Spread.Sheets.Shapes.PictureShape) {
let pic = sheet.shapes.all()
let startRow = pic.startRow()
let endRow = pic.endRow()
let startColumn = pic.startColumn()
let endColumn = pic.endColumn()
console.log(row, col, '----参数---', startRow, '---', endRow, '---pic--', pic, '---endColumn---',endColumn)
// console.log(row >= startRow && row <= endRow, '----',col >= startColumn)
if (row >= startRow && row <= endRow && col >= startColumn && col <= endColumn) {
// console.log(startRow,endRow,startColumn,endColumn)
console.log(pic,"----当前图片双击", pic.name())
}
}
}
});
function getHitAreaName(result) {
if (!result) return;
var str = '';
if (result.worksheetHitInfo) {
let type = result.worksheetHitInfo.hitTestType
switch (type) {
case 0:
str = 'corner';
case 1:
str = 'colHeader';
case 2:
str = 'rowHeader';
case 3:
return {row: result.worksheetHitInfo.row, col: result.worksheetHitInfo.col}
}
}
}
}
|
|