# HG changeset patch
# User Edouard Tisserant
# Date 1606915917 -3600
# Node ID 20a5eb6a02e69850e2405ce191b1e4ba29d6b590
# Parent  9e55061c87fa5bb3de241f3fb5eb79e49db45eed
SVGHMI: prevent unwnted context menu and pinch zoom

diff -r 9e55061c87fa -r 20a5eb6a02e6 svghmi/gen_index_xhtml.ysl2
--- a/svghmi/gen_index_xhtml.ysl2	Wed Dec 02 14:30:58 2020 +0100
+++ b/svghmi/gen_index_xhtml.ysl2	Wed Dec 02 14:31:57 2020 +0100
@@ -66,7 +66,9 @@
              xmlns:svg="http://www.w3.org/2000/svg"
              xmlns:xlink="http://www.w3.org/1999/xlink" {
             head;
-            body style="margin:0;overflow:hidden;user-select:none;" {
+            // prevents user selection by mouse click / touch and drag
+            // prevents pinch zoom and other accidental panning panning with touch devices
+            body style="margin:0;overflow:hidden;user-select:none;touch-action:none;" {
                 // Inline SVG
                 copy "$result_svg";
                 script{
diff -r 9e55061c87fa -r 20a5eb6a02e6 svghmi/svghmi.js
--- a/svghmi/svghmi.js	Wed Dec 02 14:30:58 2020 +0100
+++ b/svghmi/svghmi.js	Wed Dec 02 14:31:57 2020 +0100
@@ -311,6 +311,11 @@
 var current_page_index;
 
 function prepare_svg() {
+    // prevents context menu from appearing on right click and long touch
+    document.body.addEventListener('contextmenu', e => {
+        e.preventDefault();
+    });
+
     for(let eltid in detachable_elements){
         let [element,parent] = detachable_elements[eltid];
         parent.removeChild(element);