Posted 4 April 2025, 6:27 am EST
Hi,
The devs have suggested using the approach shown in the snippet below to simulate the double-click behavior when a custom item in the context menu is clicked:
// Function to simulate a double click at stored coordinates
function simulateDoubleClick(coords) {
// console.log(getSheetTabRect(spread, spread.getActiveSheet()));
console.log(coords)
setTimeout(() => {
const canvas = document.getElementById(tabStripID);
const mousedown = new MouseEvent("mousedown", {
bubbles: true,
cancelable: false,
clientX: coords.x,
clientY: coords.y,
view: window,
});
canvas.dispatchEvent(mousedown);
const mouseup = new MouseEvent("mouseup", {
bubbles: true,
cancelable: false,
clientX: coords.x,
clientY: coords.y,
view: window,
});
canvas.dispatchEvent(mouseup);
const event = new MouseEvent("dblclick", {
bubbles: true,
cancelable: false,
clientX: coords.x,
clientY: coords.y,
view: window,
});
canvas.dispatchEvent(event);
}, 0);
}
Please refer to the attached sample: Sample.zip
Best regards,
Priyam