two fingers press to open context menu
This commit is contained in:
parent
ddb28b33a3
commit
7195c4d42c
|
@ -107,18 +107,25 @@ var contextMenuInit = function() {
|
|||
oldMenu.remove();
|
||||
}
|
||||
});
|
||||
gradioApp().addEventListener("contextmenu", function(e) {
|
||||
['contextmenu', 'touchstart'].forEach((eventType) => {
|
||||
gradioApp().addEventListener(eventType, function(e) {
|
||||
let ev = e;
|
||||
if (eventType.startsWith('touch')) {
|
||||
if (e.touches.length !== 2) return;
|
||||
ev = e.touches[0];
|
||||
}
|
||||
let oldMenu = gradioApp().querySelector('#context-menu');
|
||||
if (oldMenu) {
|
||||
oldMenu.remove();
|
||||
}
|
||||
menuSpecs.forEach(function(v, k) {
|
||||
if (e.composedPath()[0].matches(k)) {
|
||||
showContextMenu(e, e.composedPath()[0], v);
|
||||
showContextMenu(ev, e.composedPath()[0], v);
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
eventListenerApplied = true;
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue