David Catuhe 7 anos atrás
pai
commit
c066eabaa9
2 arquivos alterados com 13 adições e 6 exclusões
  1. 6 3
      gui/src/2D/controls/control.ts
  2. 7 3
      gui/src/3D/controls/control3D.ts

+ 6 - 3
gui/src/2D/controls/control.ts

@@ -68,7 +68,7 @@ module BABYLON.GUI {
         private _fontSet = false;
         private _dummyVector2 = Vector2.Zero();
         private _downCount = 0;
-        private _enterCount = 0;
+        private _enterCount = -1;
         private _doNotRender = false;
         private _downPointerIds:{[id:number] : boolean} = {};
 
@@ -1163,10 +1163,13 @@ module BABYLON.GUI {
 
         /** @hidden */
         public _onPointerEnter(target: Control): boolean {
-            if (this._enterCount !== 0) {
+            if (this._enterCount > 0) {
                 return false;
             }
 
+            if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
+                this._enterCount = 0;
+            }
             this._enterCount++;
 
             var canNotify: boolean = this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
@@ -1209,7 +1212,7 @@ module BABYLON.GUI {
             delete this._downPointerIds[pointerId];
 
             var canNotifyClick: boolean = notifyClick;
-			if (notifyClick && this._enterCount > 0) {
+			if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
 				canNotifyClick = this.onPointerClickObservable.notifyObservers(new Vector2WithInfo(coordinates, buttonIndex), -1, target, this);
 			}
 			var canNotify: boolean = this.onPointerUpObservable.notifyObservers(new Vector2WithInfo(coordinates, buttonIndex), -1, target, this);

+ 7 - 3
gui/src/3D/controls/control3D.ts

@@ -9,7 +9,7 @@ module BABYLON.GUI {
         public _host: GUI3DManager;
         private _node: Nullable<TransformNode>;
         private _downCount = 0;
-        private _enterCount = 0;
+        private _enterCount = -1;
         private _downPointerIds:{[id:number] : boolean} = {};
         private _isVisible = true;
     
@@ -253,10 +253,14 @@ module BABYLON.GUI {
 
         /** @hidden */
         public _onPointerEnter(target: Control3D): boolean {
-            if (this._enterCount !== 0) {
+            if (this._enterCount > 0) {
                 return false;
             }
 
+            if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
+                this._enterCount = 0;
+            }
+
             this._enterCount++;
 
             this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
@@ -304,7 +308,7 @@ module BABYLON.GUI {
 
             delete this._downPointerIds[pointerId];
 
-			if (notifyClick && this._enterCount > 0) {
+			if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
 				this.onPointerClickObservable.notifyObservers(new Vector3WithInfo(coordinates, buttonIndex), -1, target, this);
 			}
 			this.onPointerUpObservable.notifyObservers(new Vector3WithInfo(coordinates, buttonIndex), -1, target, this);