iOS Question Make dialog visible

asubias

Member
Licensed User
Hello.
I made a B4XDialog that contains a DateTime Label. To change it I decided to make a DateTimeDialog based on this https://www.b4x.com/android/forum/threads/date-picker-snippet.84098/

My problem is if i show another dialog the first one closes (that not happens on B4a).
I tried reshowing the dialog but the wait for no longer works and I think i still having the older dialog in background.

Is there any way to make visible again? The dialog.Visible is read only and Base.Visible returns True...

Thank you in advance.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Why not use the built-in B4XDateTemplate?

Full example:
B4X:
Sub Process_Globals
   Public App As Application
   Public NavControl As NavigationController
   Private Page1 As Page
   Private Dialog As B4XDialog
   Private DateTemplate As B4XDateTemplate
   Private xui As XUI
   Private CustomDialogPanel As B4XView
End Sub

Private Sub Application_Start (Nav As NavigationController)
   NavControl = Nav
   Page1.Initialize("Page1")
   Page1.Title = "Page 1"
   Page1.RootPanel.LoadLayout("1")
   NavControl.ShowPage(Page1)
   DateTemplate.Initialize
   Dialog.Initialize(Page1.RootPanel)
   Dialog.Title = "B4i"
   CustomDialogPanel = xui.CreatePanel("")
   Dim btn As Button
   btn.Initialize("btn", btn.STYLE_SYSTEM)
   btn.Text = "Click to select date"
   CustomDialogPanel.SetLayoutAnimated(0, 0, 0, 300dip, 300dip)
   CustomDialogPanel.AddView(btn, 20dip, 20dip, 200dip, 100dip)
End Sub

Sub Page1_Click
   ShowFirstDialog
End Sub

Sub ShowFirstDialog
   Wait For (Dialog.ShowCustom(CustomDialogPanel, "OK", "", "")) Complete (Result As Int)
   If Result = xui.DialogResponse_Positive Then
       Dim date As Long = CustomDialogPanel.Tag
       Page1.Title = DateTime.Date(date)
   End If
End Sub

Sub btn_Click
   Dialog.Close(xui.DialogResponse_Cancel)
   Do While Dialog.Visible
       Sleep(30)
   Loop
   Wait For (Dialog.ShowTemplate(DateTemplate, "OK", "", "")) Complete (Result As Int)
   CustomDialogPanel.Tag = DateTemplate.Date
   CustomDialogPanel.GetView(0).Text = DateTime.Date(DateTemplate.Date)
   ShowFirstDialog
End Sub
 
Upvote 0

asubias

Member
Licensed User
Thanks Erel :)
Why not use the built-in B4XDateTemplate?
Because i need date and time and i like so much the iOS native datepicker desing.

Looking at your code i understand that there is no way to make visible again a dialog. The only solution is reinvoke show function and call a new wait for?
 
Upvote 0
Top