Browse Source

onDrawObservable

Royi Bernthal 7 years ago
parent
commit
4fe90665f5
2 changed files with 15 additions and 1 deletions
  1. 8 0
      gui/src/controls/container.ts
  2. 7 1
      gui/src/controls/control.ts

+ 8 - 0
gui/src/controls/container.ts

@@ -143,10 +143,18 @@ module BABYLON.GUI {
                 for (var child of this._children) {
                     if (child.isVisible && !child.notRenderable) {
                         child._draw(this._measureForChildren, context);
+
+                        if (child.onDrawObservable.hasObservers()) {
+                            child.onDrawObservable.notifyObservers(child);
+                        }
                     }
                 }
             }
             context.restore();
+
+            if (this.onDrawObservable.hasObservers()) {
+                this.onDrawObservable.notifyObservers(this);
+            }
         }
 
         public _processPicking(x: number, y: number, type: number, buttonIndex: number): boolean {

+ 7 - 1
gui/src/controls/control.ts

@@ -93,7 +93,13 @@ module BABYLON.GUI {
         * An event triggered when the control is marked as dirty
         * @type {BABYLON.Observable}
         */
-        public onDirtyObservable = new Observable<Control>();           
+        public onDirtyObservable = new Observable<Control>();         
+        
+         /**
+        * An event triggered when the control is drawn
+        * @type {BABYLON.Observable}
+        */
+        public onDrawObservable = new Observable<Control>();    
 
         public get alpha(): number {
             return this._alpha;