can I open a dialog within a dialog

melamoud

Active Member
Licensed User
Longtime User
if I have a modal dialog, and in its event I want to open a fileDialog can this be done ?

currently my dialog when call to show sub, return immidiatly without openning the file dialog
see this code (the first addFile is working, but the one from the event does not it return immidiatly as if the user press the cancel button)

B4X:
Sub btn_folders_Click
   Utilities.LogM(0,"open folders dialog")
   Dim nd As CustomDialog
   Dim ret As Int
   Dim p As Panel
   Dim l As List : l = DBHandler.getFolders
   ' build table
   p.Initialize("")
   tbl_folders.Initialize(Me,"cb",1)
   tbl_folders.AddToActivity(p,0,10,100%x,100%y-50)
   tbl_folders.SetHeader(Array As String("Folders"))
   For i = 0 To l.Size -1
      tbl_folders.AddRow(Array As String(l.Get(i)))
   Next
   
   addFile
   
   
   nd.AddView(p,0,0,100%x,100%y)      
   ret = DialogResponse.CANCEL
   ret = nd.Show("You have " & l.Size & " Folders", "Ok", "", "", Null)
End Sub

Sub cb_CellClick (Col As Int, Row As Int)
   Utilities.LogM(0,"Folders CellClick: " & Col & " , " & Row)
   Utilities.LogM(0,"cell value:" & tbl_folders.GetValue(Col, Row))
End Sub

Sub cb_HeaderClick (Col As Int)
   Utilities.LogM(0,"HeaderClick: " & Col)
   addFile
End Sub

' open file dialog and choose a file to ad to the table
Sub addFile
   Utilities.LogM(0,"AddFile: ")
   Dim nd As FileDialog
   nd.FilePath = File.DirRootExternal
   
   nd.ShowOnlyFolders = True
   Dim ret As Int
   ret = DialogResponse.CANCEL   
   ret = nd.Show("Please choose the base folder of your mp3 files","Ok","Cancel","",Null)
   If (ret = DialogResponse.POSITIVE) Then
      Utilities.LogM(0,"User press ok")
      tbl_folders.AddRow(Array As String(nd.FilePath))
   Else      
         Utilities.LogM(0,"User press cancel")
   End If

End Sub
 

melamoud

Active Member
Licensed User
Longtime User
Use CallSubDelayed to call the sub that shows the dialog.

I actually tried that it is not working,
If I tryit with the "explorer" class developed by "Informatix" it is working, but the file dialog (explorer) will only get opened after the main dialog get closed

with the dialog library it stop immidiatly (before the main dialog get closed)

anything to explain the dialog library behaviour ?
 
Upvote 0

melamoud

Active Member
Licensed User
Longtime User
this is my whole project , apart from calling it from resume or create, for some reason the button event does not work at all so I cant reproduce the issue, can you have a look ?

B4X:
Public Sub openDialog 
    Dim nd As CustomDialog
    Dim ret As Int
    Dim p As Panel
    p.Initialize("p")
   
   Dim btn As Button
   btn.Initialize("cb")
   btn.Enabled = True
   btn.Text= "Files..."
    nd.AddView(p,0,0,100%x,100%y)        
   p.AddView(btn,10,10,100,100)    
    ret = DialogResponse.CANCEL
   Log ("Before first dialog")
    ret = nd.Show("You have X Folders", "Ok", "", "", Null)
   Log ("after first dialog")
End Sub


Public Sub cb_Click 
   Log ("button pressed")
    addFile
End Sub

' open file dialog and choose a file to ad to the table
Public Sub addFile
    Dim nd As FileDialog
    nd.FilePath = File.DirRootExternal
    
    nd.ShowOnlyFolders = True
    Dim ret As Int
    ret = DialogResponse.CANCEL    
   Log ("Before second dialog")
    ret = nd.Show("Please choose the base folder of your mp3 files","Ok","Cancel","",Null)
   Log ("after second dialog return=" & ret)

    If (ret = DialogResponse.POSITIVE) Then
        ToastMessageShow(nd.FilePath,False)
    Else        
        ToastMessageShow("Canceled",False)   
    End If

End Sub
 
Upvote 0

melamoud

Active Member
Licensed User
Longtime User
How?
My real problem was with a table now that I'm thinking about it not with a panel maybe that's why my event was called.

How do I use non modal dialog ?
 
Upvote 0

melamoud

Active Member
Licensed User
Longtime User
I'm switching panel (setting visibility on and off) right now

Its working but I was hoping to use dialogs its cleaner and simpler .
 
Upvote 0
Top