Android Question Issue with Modal Dialog

bocker77

Active Member
Licensed User
Longtime User
I am using an InputMultiList and am having an issue. If I click outside of the dialog without selecting any selection or "OK" the next line of code is executed. I disabled all views and panel on the panel that the dialog sits on prior to issuing it. What I am expected since this is a modal dialog is that it would not except a click outside of itself. Am I mistaken as to how this works and if so how would I get around this issue? I am at the current release of B4A which is 8.80.
 

Eme Fibonacci

Well-Known Member
Licensed User
Longtime User
This behavior is expected. If nothing was selected then a list has a size=0. You should then deal with result.
 
Upvote 0

Eme Fibonacci

Well-Known Member
Licensed User
Longtime User
If you wanna a result mandatory then I think that you can use something like this. Maybe there's a better ways to do it.
B4X:
Dim lstResult As List
lstResult.Initialize
Do While lstResult.Size=0
     lstResult=InputMultiList(lstItems,"Select")
Loop
 
Upvote 0

bocker77

Active Member
Licensed User
Longtime User
Erel,

So if I use the async version then the panel behind the dialog will be disabled? That is what my problem is. If the user accidentally touches outside of the dialog it proceeds to the next line of code. This also happens with Msgbox2 also but I figured out how to prevent this from happening as long as I only use "Positive" and "Negative" responses.

So all explanations in the Basic4Android book by Wyken Seagrave from 2013 for modal dialogs are no longer relevant? I will change my code to use the async versions but again will this solve my main problem?

Thanks,
Greg
 
Upvote 0

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
Try making a panel the size of the activity with a transparent background that is displayed just before your WaitFor, and discard it's click event (be sure make the panel's elevation higher than any of your other views, esp. buttons).
B4X:
'...
PseudoModalPanel.Visible = True
Waitfor …
PseudoModalPanel.Visible = False
'...

Private Sub PseudoModalPanel_Click()
     'discard
End Sub
 
Last edited:
Upvote 0

walterf25

Expert
Licensed User
Longtime User
Erel,

So if I use the async version then the panel behind the dialog will be disabled? That is what my problem is. If the user accidentally touches outside of the dialog it proceeds to the next line of code. This also happens with Msgbox2 also but I figured out how to prevent this from happening as long as I only use "Positive" and "Negative" responses.

So all explanations in the Basic4Android book by Wyken Seagrave from 2013 for modal dialogs are no longer relevant? I will change my code to use the async versions but again will this solve my main problem?

Thanks,
Greg
Do As @Erel suggested, that should work, even if the user presses outside of the dialog the dialog will not be dismissed.

Walter
 
Upvote 0

bocker77

Active Member
Licensed User
Longtime User
Erel,

OK I changed all my modal dialogs to use the async versions, replacing InputMultiList with InputMapAsync and the "Cancelable Boolean" parameter solves my problem. I use the NumberDialog also and am wondering if there is an async version for that.

Greg
 
Upvote 0
Top