Need help regarding touch events in IOS to open context menu


#1

The web app works on dhtmlx 5.0 and wijmo grid. The context menu works fine on android by holding touch but doesn’t work when used on Iphone’s safari browser. I want the context to be opened with a touch ‘press and hold’ event on safari as in chrome. please help me whether I need to include a library or is there any event for this.


#2

Please, try to simulate your own longPress with the following code:

var timer;

function onlongtouch(x,y){
	timer = null;
    myContextMenu.showContextMenu(x, y);
}
function touchstart(e) {
	var x = e.touches[0].clientX
	var y = e.touches[0].clientY
    if (!timer) {
        timer = setTimeout(function(){onlongtouch(x,y)}, 800);
    }
}

function touchend() {
    if (timer) {
        clearTimeout(timer);
        timer = null;
    }
}

document.addEventListener("DOMContentLoaded", function(event) { 
    window.addEventListener("touchstart", touchstart, false);
    window.addEventListener("touchend", touchend, false);
});

Here is a working example:
http://snippet.dhtmlx.com/5/f0a993511