Background:
I need to check for the input that the users feed the library dialog with; if it does not meet the criteria, the dialog should not close until it does or the user cancels.
Basically, an EditText should not be empty (that is built into the library dialog).
Problem:
I have not found a way on how to prevent that the DialogPanel closes after the user hits "Yes".
The diagram flow will be: I need to let the user click "Yes", check if the criteria is met, and if it is not, the dialog should stay with the data that has been filled already.
I am using Erel Example in his second post. As in example, if do you want to do something you should fill it up with an Edit Text that I set there below it; I would like to send a toast message "no action input!" but leave the Dialog open so they can still work on it.
Further thoughts
I know that if I use 'If Result = DialogResponse.POSITIVE And EditText.Text = "" then'
and then handle by that logic, however, I am going to work with multiple criteria later on and I would like to know how to prevent the Dialog close to handle any future scenario that might come along
I need to check for the input that the users feed the library dialog with; if it does not meet the criteria, the dialog should not close until it does or the user cancels.
Basically, an EditText should not be empty (that is built into the library dialog).
Problem:
I have not found a way on how to prevent that the DialogPanel closes after the user hits "Yes".
The diagram flow will be: I need to let the user click "Yes", check if the criteria is met, and if it is not, the dialog should stay with the data that has been filled already.
B4X:
Sub btnEnterDetails_Click
Dim dialog As CustomLayoutDialog
Dim sf As Object = dialog.ShowAsync("", "Yes", "Cancel", "No", Null, False)
Wait For (sf) Dialog_Ready (DialogPanel As Panel)
DialogPanel.LoadLayout("DetailsDialog")
Dim disable() As Boolean = Array As Boolean(False)
AutoClose(dialog, lblSeconds, disable)
Wait For (sf) Dialog_Result (Result As Int)
disable(0) = True 'disable the AutoClose timer
sf.Preserve 'Something like this to prevent closing while evaluating criteria
If Result = DialogResponse.POSITIVE Then
If EditText.Text = "" then
ToastMessageShow("Write something!", False)
else
sf.close 'Something like this to prevent closing while evaluating criteria
end if
End If
End Sub
Sub AutoClose (TimedDialog As CustomLayoutDialog, UpdateLabel As Label, Disable() As Boolean)
UpdateLabel.Text = 9 '9 seconds
Do While UpdateLabel.Text > 0
Sleep(1000)
'the timer was disabled
If Disable(0) = True Then Return
UpdateLabel.Text = NumberFormat(UpdateLabel.Text - 1, 0, 0)
Loop
TimedDialog.CloseDialog(DialogResponse.CANCEL)
End Sub
Further thoughts
I know that if I use 'If Result = DialogResponse.POSITIVE And EditText.Text = "" then'
and then handle by that logic, however, I am going to work with multiple criteria later on and I would like to know how to prevent the Dialog close to handle any future scenario that might come along
Last edited: