I am sure there is something fundamental I am missing here....
I wish to send a value to a B4X Custom Dialogue as a default value, display the dialogue and allow the user to modify it, then perform a calculation with the result. Unfortunately the example code uses 'Wait For' so can only return a Resumeable Sub. In the code below the Log() reports 'I'm Back' before the user has modified anything. I have tried using a Global variable within the Dialoge code but it returns before user input occurs with an incorrect value. I have tried putting the 'Calculate' Sub within the 'If Result = xui.DialogResponse_Positive' but it appears to be return zero all the time.
I wish to use this Dialogue to modify several different values in the app. What is the correct technique to use?
I wish to send a value to a B4X Custom Dialogue as a default value, display the dialogue and allow the user to modify it, then perform a calculation with the result. Unfortunately the example code uses 'Wait For' so can only return a Resumeable Sub. In the code below the Log() reports 'I'm Back' before the user has modified anything. I have tried using a Global variable within the Dialoge code but it returns before user input occurs with an incorrect value. I have tried putting the 'Calculate' Sub within the 'If Result = xui.DialogResponse_Positive' but it appears to be return zero all the time.
I wish to use this Dialogue to modify several different values in the app. What is the correct technique to use?
Hours & Minutes to minutes:
Sub btnStartTime_Click
ShowHoursDialog("Enter Start Time",StartTime)
Log("I'm Back")
CalculateResult
End Sub
Sub ShowHoursDialog(Prompt As String, Default As Int)
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, 250dip, 150dip) 'set the content size
p.LoadLayout("dialog")
Dialog.Title = Prompt
Dialog.BlurBackground = True
For t = 0 To 23
B4XComboHours.cmbBox.Add(NumberFormat(t,2,0))
Next
For t = 0 To 55 Step 5
B4XComboMins.cmbBox.Add(NumberFormat(t,2,0))
Next
B4XComboHours.cmbBox.SelectedIndex = Default / 60
B4XComboMins.cmbBox.SelectedIndex = (Default Mod 60) / 5
Dim rs As ResumableSub = Dialog.ShowCustom(p, "OK", "", "Cancel")
Wait For (rs) Complete(Result As Int)
If Result = xui.DialogResponse_Positive Then
Default = (B4XComboHours.cmbBox.SelectedItem * 60) + B4XComboMins.cmbBox.SelectedItem
End If
Return Default '???????????
End Sub