• HelpOpenFL
  • Confusion about layout variable in StackNavigator

Hi,
In the program given at https://feathersui.com/learn/haxe-openfl/stack-navigator/, there are two classes ViewA and ViewB. These two classes are defining a variable with name layout as follows:

layout = new VerticalLayout();

However this variable has not been used inside these classes. But when I am removing this code then in output the value of label is not being displayed. Only buttons are being displayed. When using this layout variable then label is also appearing in the output. When layout is not connected with label in any way then why label is not displaying on removing the variable layout? Can any one explain it to me?

Best Regards ...
Pankaj Kumar

The ViewA and ViewB classes extend feathers.controls.LayoutGroup. The layout property is inherited from this superclass.

When you don't set a layout, the Label and the Button are both positioned at (0, 0). The Label is behind the Button, so you can't see it, but it's there.

    joshtynjala Thanks for clarifications. As you told that when we don't define layout then Label and Button are both positioned at (0,0). But after defining layout we are not setting the coordinates of Label and Button. So how their coordinates automatically differ after defining the layout variable?

      ccpplinux But after defining layout we are not setting the coordinates of Label and Button. So how their coordinates automatically differ after defining the layout variable?

      The code inside the layout class sets the coordinates of the Label and Button. That's what layouts are for.