浏览代码

gui: Better fix for onblur

David Catuhe 8 年之前
父节点
当前提交
906bc03052

+ 1 - 0
dist/preview release/gui/babylon.gui.d.ts

@@ -35,6 +35,7 @@ declare module BABYLON.GUI {
         private _doPicking(x, y, type);
         attach(): void;
         attachToMesh(mesh: AbstractMesh): void;
+        private _attachToOnBlur(scene);
         static CreateForMesh(mesh: AbstractMesh, width?: number, height?: number): AdvancedDynamicTexture;
         static CreateFullscreenUI(name: string, foreground?: boolean, scene?: Scene): AdvancedDynamicTexture;
     }

+ 15 - 10
dist/preview release/gui/babylon.gui.js

@@ -223,16 +223,7 @@ var BABYLON;
                     _this._doPicking(scene.pointerX, scene.pointerY, pi.type);
                     pi.skipOnPointerObservable = _this._shouldBlockPointer && pi.type !== BABYLON.PointerEventTypes.POINTERUP;
                 });
-                this._canvasBlurObserver = scene.getEngine().onCanvasBlurObservable.add(function () {
-                    if (_this._lastControlOver && _this._lastControlOver.onPointerOutObservable.hasObservers()) {
-                        _this._lastControlOver.onPointerOutObservable.notifyObservers(_this._lastControlOver);
-                    }
-                    _this._lastControlOver = null;
-                    if (_this._lastControlDown) {
-                        _this._lastControlDown.forcePointerUp();
-                    }
-                    _this._lastControlDown = null;
-                });
+                this._attachToOnBlur(scene);
             };
             AdvancedDynamicTexture.prototype.attachToMesh = function (mesh) {
                 var _this = this;
@@ -253,6 +244,20 @@ var BABYLON;
                         _this._lastControlDown = null;
                     }
                 });
+                this._attachToOnBlur(scene);
+            };
+            AdvancedDynamicTexture.prototype._attachToOnBlur = function (scene) {
+                var _this = this;
+                this._canvasBlurObserver = scene.getEngine().onCanvasBlurObservable.add(function () {
+                    if (_this._lastControlOver && _this._lastControlOver.onPointerOutObservable.hasObservers()) {
+                        _this._lastControlOver.onPointerOutObservable.notifyObservers(_this._lastControlOver);
+                    }
+                    _this._lastControlOver = null;
+                    if (_this._lastControlDown) {
+                        _this._lastControlDown.forcePointerUp();
+                    }
+                    _this._lastControlDown = null;
+                });
             };
             // Statics
             AdvancedDynamicTexture.CreateForMesh = function (mesh, width, height) {

文件差异内容过多而无法显示
+ 2 - 2
dist/preview release/gui/babylon.gui.min.js


+ 18 - 12
gui/src/advancedDynamicTexture.ts

@@ -248,18 +248,7 @@ module BABYLON.GUI {
                 pi.skipOnPointerObservable = this._shouldBlockPointer && pi.type !== BABYLON.PointerEventTypes.POINTERUP;
             });
 
-            this._canvasBlurObserver = scene.getEngine().onCanvasBlurObservable.add(() => {
-                if (this._lastControlOver && this._lastControlOver.onPointerOutObservable.hasObservers()) {
-                    this._lastControlOver.onPointerOutObservable.notifyObservers(this._lastControlOver);
-                }
-                
-                this._lastControlOver = null;
-
-                if (this._lastControlDown) {
-                    this._lastControlDown.forcePointerUp();
-                }
-                this._lastControlDown = null;                
-            });
+            this._attachToOnBlur(scene);
         }
 
         public attachToMesh(mesh: AbstractMesh): void {
@@ -280,6 +269,23 @@ module BABYLON.GUI {
                     this._lastControlDown = null;  
                 }
             });
+
+            this._attachToOnBlur(scene);
+        }
+
+        private _attachToOnBlur(scene: Scene): void {
+            this._canvasBlurObserver = scene.getEngine().onCanvasBlurObservable.add(() => {
+                if (this._lastControlOver && this._lastControlOver.onPointerOutObservable.hasObservers()) {
+                    this._lastControlOver.onPointerOutObservable.notifyObservers(this._lastControlOver);
+                }
+                
+                this._lastControlOver = null;
+
+                if (this._lastControlDown) {
+                    this._lastControlDown.forcePointerUp();
+                }
+                this._lastControlDown = null;                
+            });
         }
 
         // Statics