B4J Question Find Form that contain a Node

Teech

Member
Licensed User
Longtime User
I have a Layout used in lots of forms and pane, loaded with [container].LoadLayout. In my class i have a Sub like this:
B4X:
Public Sub LoadLayout(parent As Object,caller As Object)
    mCaller=caller
    If parent Is TabPane Then
        Dim t As TabPane=parent
        t.LoadLayout("EmployeesList","Employees")
    End If
    If parent Is Form Then
        Dim f As Form= parent
        f.RootPane.LoadLayout("EmployeesList")
    End If
    FillEmployeesView
End Sub
This Layout (EmployeesList) has a button that show a DirectoryChooser.
Unfotunatelly i can't find which form is in use to pass as argument in DirectoryChooser.Show.
B4X:
Sub btCSV_Click
    Dim d As DirectoryChooser
    d.Initialize
    d.InitialDirectory=File.DirTemp
    Dim dir As String   
    dir=d.Show(???) '<--- PROBLEM
   
    If dir<>"" Then
      'Do Something
    End If
End Sub
Could someone help me?
Many thanks
 

MarkusR

Well-Known Member
Licensed User
Longtime User
does it work with?
B4X:
d.Show(MainForm)
d.Show(Main.MainForm)
B4X:
Sub Process_Globals

    Public MainForm As Form

End Sub
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
You could just create a form to use
B4X:
Sub btCSV_Click
    Dim d As DirectoryChooser
    d.Initialize
    d.InitialDirectory=File.DirTemp
    Dim dir As String
    Dim f As Form   ' doesn't even need to be initialized <--- Solution
    dir=d.Show(f) '<--- PROBLEM
   
    If dir<>"" Then
      'Do Something
    End If
End Sub
 
Upvote 0
Top