Sfoglia il codice sorgente

Merge pull request #2942 from aWeirdo/patch-15

Update button.ts
David Catuhe 7 anni fa
parent
commit
8ceda22d96
1 ha cambiato i file con 18 aggiunte e 1 eliminazioni
  1. 18 1
      gui/src/controls/button.ts

+ 18 - 1
gui/src/controls/button.ts

@@ -136,5 +136,22 @@ module BABYLON.GUI {
 
             return result;
         }
+        
+        public static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button {
+            var result = new Button(name);
+
+            // Adding image
+            var iconImage = new BABYLON.GUI.Image(name + "_icon", imageUrl);
+            iconImage.stretch = BABYLON.GUI.Image.STRETCH_FILL;
+            result.addControl(iconImage);         
+            
+            // Adding text
+            var textBlock = new BABYLON.GUI.TextBlock(name + "_button", text);
+            textBlock.textWrapping = true;
+            textBlock.textHorizontalAlignment = BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER;
+            result.addControl(textBlock);   
+
+            return result;
+        }
     }    
-}
+}