B4J Question Panel inside panel - What am I doing wrong!

davemorris

Active Member
Licensed User
Longtime User
Hi,
I am trying to place panels inside panels and getting strange behaviour.

Basically I am trying to use loadlayout (Instead of my normal addview/addnode). But when I load the new panel inside the original its border appears to disappear (but the contents remains)?

I have put together a test project to highlight the problem - click on the buttons 1 , 2 and 3 in that order an you will the the proceeding border disappear.
However, if you click the buttons in the reverse order i.e. 3, 2 and 1 - then all is well.

I looks to me that the loaded panel removes its parent panel border but there are examples on the forum which suggest this method will work.

I would appreciate if someone could have a look at my simple example

Kind regards
Dave
 

Attachments

  • PanelInsidePanel.zip
    6.2 KB · Views: 84

walt61

Well-Known Member
Licensed User
Longtime User
Have a look at the attached: it shows what's going on. I've changed the colour and width of the 'Main' object in the two sub-layouts. When loading the layout into the pane, it takes over the entire pane. As the sub-layouts' 'Main' objects didn't have a border width, the parent's appeared to vanish but was actually overwritten.
 

Attachments

  • PanelInsidePanel.zip
    6.4 KB · Views: 82
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
but was actually overwritten.
not overwritten.... Imagine a you add a panel to your Main.root (which in it self is a panel), lets call it Panel1. Then you add a second panel to Panel1, let's call it panel2. If both panels have the anchor points set to be 0 Top, 0 FromRight, 0 Left, 0 FromBottom, then they occupy entirely their parent, but they do NOT overwrite them....
Panel2 parent is STILL panel1, and panel1 parent is STILL root.
If however, you set, lets say Panel2 to be 50% from Left, 0 from right, 50% from top, 0 from bottom, thus occupying 25% of panel 1, any control/view placed in Panel1 within those un-occupied 75% are still visible!
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
It's up to the developer to be ware of views naming... if 2 or more views have the same name but in different layouts, if they are loaded at the same time, trouble appears!!!
heres a test project, in it there are 3 layouts: MainLayout, Panel1 and Panel2, rsulting in this screen:
1750787785150.png

Each of the visible views has a different parent, but to the user they appear as belonging to the same Pane (root)
In this case, the Button's parent is Root, The ToggleButton's parent is Panel1 and the DatePicker's parent is Panel2
 

Attachments

  • teste.zip
    5 KB · Views: 75
Upvote 0

davemorris

Active Member
Licensed User
Longtime User
Hi, Guys
Thanks for input -but I must be missing the point This is what I am trying to achieve

Panels.JPG


But I only get this

OnlyLastPanel.JPG


So if the contents of the panels are displayed - I still can't understand why all the panels are not shown.

Regards
Dave
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
From your screenshot, they are being shown, just not the borders.
you need to understand that borders are INSET, meaning that a 5dip border starts at Top = 0 and Left = 0 and extends itself to Top = 5 and Left = 5, and the same all around.
When you load a new layout, it will take all the space from Top = 0 and Left = 0 up to panel.width and panel.height, thus hidding the parent panel border.
If you need the borders to appears, set them on the child panel.
1750834580488.png
 

Attachments

  • teste.zip
    5 KB · Views: 78
Upvote 0
Top