Android Question Tap outside Msgbox2

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
Hello,
i use an msgbox2 to interact with the user. I save the int value returned into a variable, that assume differents value, as you can see:

B4X:
Dim m As Int
m = Msgbox2 ( "Message", "Title", "YES", "MAYBE", "NOT", NULL );

If m = DialogResponse.NEGATIVE Then Return (m = -2)
          
If m = DialogResponse.POSITIVE Then (m = -1)
....
end if
          
If m = DialogResponse.CANCEL Then (m = -3)
....
end if


But, if I tap OUTSIDE the Msgbox2, I have a result that is "-3".

How do I have a null result, or something like "0"?
 

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
You don't need to return the value if m = dialogresponse.*, DialogResponse is already an int value. You can write a small sub like this if want to get 0 if an user presses outside the msgbox, but remember that press outside and press cancel are the same case

B4X:
Dim i As Int = ReturnValue

Sub ReturnValue As Int
    Dim i As Int = Msgbox2("ok","nice","yes","cancel","neg",Null)
    If i = -3 Then Return 0
    Return i
End Sub

As you can see above, I use all 3 buttons to do some action afterwards. So, I need to get a different value
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0
Top