Double click triggering Single Click

Posted by: seshareddy.kamaganiguntla on 14 April 2022, 1:26 am EST

    • Post Options:
    • Link

    Posted 14 April 2022, 1:26 am EST

    Hii ,

    We have a usecase , where we require single click to perform some task and double click to perform another task . But double click is triggering single click event before double click is made. How to avoid that?

  • Posted 14 April 2022, 7:28 am EST

    Hi,

    We are able to observe the issue at our end hence we have escalated this issue to the concerned team for further investigation. We will update you regarding this as we get any information from the team. The internal ID for this issue will be SJS-12660.

    Till then, You may throttle the number of clicks on the spreadJS host and differentiate between click and double click by yourself. Please refer to the following code snippet and let me know if you face any issues.

    
    var clicks = 0, delay = 600;
    spread.getHost().addEventListener('mousedown', function (e) {
        e.preventDefault();
        clicks++;
        setTimeout(() => {
            var y = e.pageY - this.offsetTop;
            var x = e.pageX - this.offsetLeft
            var result = spread.hitTest(x, y);
            var wInfo = result.worksheetHitInfo;
            //if the click in inside the vievport
            if (wInfo && wInfo.hitTestType === 3) {
                let { row, col } = wInfo;
                if (clicks === 2) {
                    console.log("double click happen on cell("+row+","+col+")");
                } else if (clicks === 1) {
                    console.log("Single click happen on cell("+row+","+col+")")
                }
            }
            clicks = 0;
            return;
    
        }, delay);
    
    }, true);
    
    

    sample: https://jscodemine.grapecity.com/share/utGdSSYDOEK_HEJbTZxa3w/

    regards,

    Avinash

  • Posted 16 April 2022, 11:34 am EST

    addEventListener(“name-of-event”, function(e) { console. log(e. detail); // Prints “Example of an event” }); // Create the event var event = new CustomEvent(“name-of-event”, { “detail”: “Example of an event” }); // Dispatch/Trigger/Fire the event document. dispatchEvent(event);

  • Posted 18 April 2022, 7:42 am EST

    Hi,

    The devs informed us that this is by design. You may also use the following snippet to achieve the same.

    
    var time = null;
    spread.bind(GC.Spread.Sheets.Events.CellClick, function (sender, args) {
        clearTimeout(time);
        time = setTimeout(function () {
            console.log("Cell Click")
        }, 300);
    });
    spread.bind(GC.Spread.Sheets.Events.CellDoubleClick, function (sender, args) {
        clearTimeout(time);
        console.log("Double Click")
    }); 
    
    

    Regards,

    Avinash

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels