B4J Question Add pane at runtime

Hi everyone,
What am I doing wrong when to add a pane to rootpane?
It doesn't appear and logs 0 to with and height.

B4X:
CSSUtils.SetStyleProperty(p, "-fx-rotate","45" )
      
            
      MainForm.RootPane.AddNode(p,P.Left,P.Top,P.Width,P.Height)
      Log(P.Width & "    " & P.Height)
      P.Visible = True
      'xui.MsgboxAsync("Hello World!", "B4X")
End Sub
 

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
Most likely width and height don't settle until the the UI is fully rendered. It's better to use prefWidth and prefHeight
 
Upvote 0
Thank you for your answer.
I did used that options for the size. What is the correct procedure to add pane to any pane at runtime.
Thanks in advance
 
Upvote 0

teddybear

Well-Known Member
Licensed User
Hi everyone,
What am I doing wrong when to add a pane to rootpane?
It doesn't appear and logs 0 to with and height.

B4X:
CSSUtils.SetStyleProperty(p, "-fx-rotate","45" )
      
            
      MainForm.RootPane.AddNode(p,P.Left,P.Top,P.Width,P.Height)
      Log(P.Width & "    " & P.Height)
      P.Visible = True
      'xui.MsgboxAsync("Hello World!", "B4X")
End Sub
Where and how do you define and initialize the pane P?
 
Upvote 0
Tip: you should never see Pane, PrefWidth and PrefHeight in your code.

B4X:
Dim pnl As B4XView = XUI.CreatePanel("pnl")
pnl.SetLayoutAnimated(0, ...) 'not really needed as you should add the panel to the parent at this point.
pnl.Rotation = 45
...
Thanks Erel.
This is for the purpose of my learning:
can I assign mouse events to each panel using the respective tag as a filter in MainForm.RootPane.GetAllViewsRecursive, I mean without having to write a separate method for each panel?
 
Upvote 0
Top