Sfoglia il codice sorgente

Pointer capture and release

with exception handling.
Raanan Weber 9 anni fa
parent
commit
582222d05c

+ 12 - 3
src/Cameras/Inputs/babylon.arcrotatecamera.input.pointers.ts

@@ -40,7 +40,12 @@ module BABYLON {
             this._pointerInput = (p, s) => {
                 var evt = <PointerEvent>p.event;
                 if (p.type === PointerEventTypes.POINTERDOWN) {
-//                    evt.srcElement.setPointerCapture(evt.pointerId);
+                    try {
+                        evt.srcElement.setPointerCapture(evt.pointerId);
+                    } catch (e) {
+                        //Nothing to do with the error. Execution will continue.
+                    }
+
 
                     // Manage panning with right click
                     this._isRightClick = evt.button === 2;
@@ -52,8 +57,12 @@ module BABYLON {
                         evt.preventDefault();
                     }
                 } else if (p.type === PointerEventTypes.POINTERUP) {
-//                    evt.srcElement.releasePointerCapture(evt.pointerId);
-
+                    try {
+                        evt.srcElement.releasePointerCapture(evt.pointerId);
+                    } catch (e) {
+                        //Nothing to do with the error.
+                    }
+                    
                     cacheSoloPointer = null;
                     previousPinchDistance = 0;
 

+ 10 - 2
src/Cameras/Inputs/babylon.freecamera.input.mouse.ts

@@ -18,7 +18,11 @@ module BABYLON {
                 this._pointerInput = (p, s) => {
                     var evt = <PointerEvent>p.event;
                     if (p.type === PointerEventTypes.POINTERDOWN) {
-//                        evt.srcElement.setPointerCapture(evt.pointerId);
+                        try {
+                            evt.srcElement.setPointerCapture(evt.pointerId);
+                        } catch (e) {
+                            //Nothing to do with the error. Execution will continue.
+                        }
 
                         this.previousPosition = {
                             x: evt.clientX,
@@ -30,7 +34,11 @@ module BABYLON {
                         }
                     }
                     else if (p.type === PointerEventTypes.POINTERUP) {
-//                        evt.srcElement.releasePointerCapture(evt.pointerId);
+                        try {
+                            evt.srcElement.releasePointerCapture(evt.pointerId);
+                        } catch (e) {
+                            //Nothing to do with the error.
+                        }
                         this.previousPosition = null;
                         if (!noPreventDefault) {
                             evt.preventDefault();