I have wrapped the HBox pane which seems to be working fine apart from the resize.
Resizing of the controls contained by the HBox works fine.
If I set the HGrow of the textfield to "SOMETIMES" it expands to fill the space as expected.
I set the MinWidth property of the HBox to 200 and resize the form and the HBox doesn't resize.
I am obviously missing something but I am not sure what? I thought resizing was controlled by the parent pane and setting a minWidth would tell the parent what the minimum width of a node could be.
Output of the log from the last image after pressing the Press Me button:
Resizing of the controls contained by the HBox works fine.
If I set the HGrow of the textfield to "SOMETIMES" it expands to fill the space as expected.
I set the MinWidth property of the HBox to 200 and resize the form and the HBox doesn't resize.
B4X:
#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 200
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Dim ABox As HBox
Dim Btn1 As Button
Dim Btn2 As Button
Dim Btn3 As Button
Dim txt1 As TextField
Dim PN1 As Pane
Dim I As Image
Dim JO As JavaObject
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.Show
Btn1.Initialize("Btn_1")
Btn2.Initialize("Btn_2")
Btn3.Initialize("Btn_3")
txt1.Initialize("txt_1")
PN1.Initialize("PN1")
ABox.Initialize("Hbox")
ABox.setPadding(10,10,10,10)
ABox.Spacing = 10
ABox.FillHeight = True
ABox.PrefWidth = 300
txt1.PrefWidth = 50
Btn1.Text = "Press Me"
ABox.AddNode(Btn1)
ABox.AddNode(Btn2)
ABox.AddNode(Btn3)
ABox.AddNode(txt1)
ABox.setHgrow(txt1,"SOMETIMES")
ABox.MinWidth =200
MainForm.RootPane.AddNode(ABox,10,10,400,40)
Log(ABox.MinWidth)
MainForm.RootPane.AddNode(PN1,12,100,400,40)
CSSUtils.SetBackgroundColor(ABox,fx.Colors.DarkGray)
CSSUtils.SetBackgroundColor(PN1,fx.Colors.DarkGray)
End Sub
'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub
Sub Btn_1_MouseClicked (EventData As MouseEvent)
Dim FN As String = Rnd(1,1000000) & ".png"
I = MainForm.RootPane.Snapshot
Dim Out As OutputStream = File.OpenOutput("C:\_2",FN,False)
I.WriteToStream(Out)
Out.Close
Log("Hbox Min Width: " & ABox.MinWidth)
Log("HBox Width: " & ABox.Width)
Log("MainForm Width: " & MainForm.Width)
Log("RootPane Widht:" &MainForm.RootPane.Width)
End Sub
I am obviously missing something but I am not sure what? I thought resizing was controlled by the parent pane and setting a minWidth would tell the parent what the minimum width of a node could be.
Output of the log from the last image after pressing the Press Me button:
B4X:
Hbox Min Width: 200
HBox Width: 400
MainForm Width: 343
RootPane Widht:343