Browse Source

item passed to push

Royi Bernthal 7 years ago
parent
commit
e27c685048
1 changed files with 19 additions and 17 deletions
  1. 19 17
      gui/src/controls/multiLine.ts

+ 19 - 17
gui/src/controls/multiLine.ts

@@ -49,25 +49,27 @@ module BABYLON.GUI {
             this._markAsDirty();
         }
 
-        public add(...items: (AbstractMesh | Control | { x: string | number, y: string | number })[]): void {
-            items.forEach(item => {
-                var point: MultiLinePoint = this.push();
-
-                if (item instanceof AbstractMesh) {
-                    point.mesh = item;
-                }
-                else if (item instanceof Control) {
-                    point.control = item;
-                }
-                else if (item.x != null && item.y != null) {
-                    point.x = item.x;
-                    point.y = item.y;
-                }
-            });
+        public add(...items: (AbstractMesh | Control | { x: string | number, y: string | number })[]): MultiLinePoint[] {
+            return items.map(item => this.push(item));
         }
 
-        public push(): MultiLinePoint {
-            return this.getAt(this._points.length);
+        public push(item?: (AbstractMesh | Control | { x: string | number, y: string | number })): MultiLinePoint {
+            var point: MultiLinePoint = this.getAt(this._points.length);
+
+            if (item == null) return point;
+
+            if (item instanceof AbstractMesh) {
+                point.mesh = item;
+            }
+            else if (item instanceof Control) {
+                point.control = item;
+            }
+            else if (item.x != null && item.y != null) {
+                point.x = item.x;
+                point.y = item.y;
+            }
+
+            return point;
         }
 
         public remove(value: number | MultiLinePoint): void {