0

To keep it short and simple, I'm doing a mosync nativeUI javascript project. Here's part of my code:

var myScreen = mosync.nativeui.create("Screen" ,"myScreen", {
               "title": "My Screen"
          });             
          //Create a Button
           var myButton = mosync.nativeui.create("Button" ,"myButton",
           {
              //properties of the button
              "width": "FILL_AVAILABLE_SPACE",
              "text": "Click Me!"
           });


        var myLayout = mosync.nativeui.create("VerticalLayout", "myLayout", 
        {
            "data-width":"FILL_AVAILABLE_SPACE", 
            "data-height":"FILL_AVAILABLE_SPACE"
        });

        myLayout.addTo("myScreen");

        //myButton.addTo("myLayout");
        myLayout.addChild("myButton");

This works, I get a new tab in my screen and the button is there.

But, if I change the last two lines and use addTo instead of addChild for adding the button to the layout, the button is not displayed.

Shouldn't the myButton.addTo("myLayout") be the same as myLayout.addChild("myButton")??

None None
  • 537
  • 2
  • 8
  • 15

1 Answers1

0

OK, I figurd it out: it depends WHEN you declair VerticalLayout. If it's defined BEFORE button, then you can use addTo.

If VerticalLayout is defined AFTER button, you must use addChild.

None None
  • 537
  • 2
  • 8
  • 15