Android Question Arguments of Msgbox2Async, wrong order?

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Found that the order of the arguments of Msgbox2Async come out the wrong way:

B4X:
Msgbox2Async("Do clickable patient markers?", "List patients to map", _
"Cancel", "Yes", "No", General.bmpIcon32, False)
Wait For Msgbox_Result(iResult As Int)

Makes the buttons come out as:

Yes No Cancel

And that is how I want it, but the arguments description suggests I should do:

B4X:
Msgbox2Async("Do clickable patient markers?", "List patients to map", _
"Yes", "Cancel", "No", General.bmpIcon32, False)
Wait For Msgbox_Result(iResult As Int)

Is this a bug somewhere in B4A or am I overlooking something?
Using the latest version.

RBS
 

klaus

Expert
Licensed User
Longtime User
I agree with RE Smisseart, the result is confusing.
With:
Msgbox2Async("Do clickable patient markers?", "List patients to map", "1", "2", "3", General.bmpIcon32, False)
The result is:
upload_2018-8-6_9-14-17.png

The order in the calling line "1", "2", "3" becomes 2 3 1 in the result.
I find this confusint too.
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
You don't have control over the buttons order. You set the "positive", "negative" and "neutral/cancel" buttons. Different devices can show them in different order.

I still have a feeling that there is something not quite right there.
I find that not only is the order of the buttons unpredictable, the result output (so -1, -2, -3 depending on what button was pressed) is somewhat unpredictable as well.
Because of this I find that when adding a new Msgbox2Async I always need to check first what the output results will be depending on the pressed button. It would be helpful at least if there was some documentation of the logic of the relation between button text, button placing and output result.
See for example this code:

B4X:
Sub TestMsgbox2Async
 
 Dim i As Int
 
 Log("1, 2, 3")
 
 For i = 1 To 3
  Msgbox2Async("Message", "Title", _
      1, 2, 3,  Null, False)
  Wait For Msgbox_Result(iResult As Int)
  Log("iResult: " & iResult)
 Next
 
 Log("Remove Marker, OK, List at Location")

 For i = 1 To 3
  Msgbox2Async("Message", "Title", _
     "Remove Marker", "OK", "List at Location",  Null, False)
  Wait For Msgbox_Result(iResult As Int)
  Log("iResult: " & iResult)
 Next
 
 Log("OK, Cancel, No")
 
 For i = 1 To 3
  Msgbox2Async("Message", "Title", _
     "OK", "Cancel", "No",  Null, False)
  Wait For Msgbox_Result(iResult As Int)
  Log("iResult: " & iResult)
 Next
 
 Log("Yes, No, """"")
 
 For i = 1 To 2
  Msgbox2Async("Message", "Title", _
     "Yes", "No", "",  Null, False)
  Wait For Msgbox_Result(iResult As Int)
  Log("iResult: " & iResult)
 Next
 
 Log("No, Yes, """"")
 
 For i = 1 To 2
  Msgbox2Async("Message", "Title", _
     "No", "Yes", "",  Null, False)
  Wait For Msgbox_Result(iResult As Int)
  Log("iResult: " & iResult)
 Next
 
 Log("No, """", Yes")
 
 For i = 1 To 2
  Msgbox2Async("Message", "Title", _
     "No", "", "Yes",  Null, False)
  Wait For Msgbox_Result(iResult As Int)
  Log("iResult: " & iResult)
 Next
 
End Sub


RBS
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
the result output (so -1, -2, -3 depending on what button was pressed) is somewhat unpredictable as well.
No, it isn't.
From the help:
Msgbox2Async(Message As CharSequence, Title As CharSequence, Positive As String, Cancel As String, Negative As String, Icon As BitmapWrapper, Cancelable As Boolean)
The first button in the calling line is Positive, the second one is Cancel and the third one is Negative.
Then check the iResult value.
B4X:
Select iResult
    Case DialogResponse.POSITIVE
        Log("You selected the Positive button") '
    Case DialogResponse.NEGATIVE
        Log("You selected the Negative button")
    Case DialogResponse.CANCEL
        Log("You selected the Cancel button")
End Select
This works, independant of the button position displayed in the message box.

upload_2018-8-7_9-4-17.png


Attached, my test program.
 

Attachments

  • TestMsgBox.zip
    8 KB · Views: 182
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
No, it isn't.
From the help:
Msgbox2Async(Message As CharSequence, Title As CharSequence, Positive As String, Cancel As String, Negative As String, Icon As BitmapWrapper, Cancelable As Boolean)
The first button in the calling line is Positive, the second one is Cancel and the third one is Negative.
Then check the iResult value.
B4X:
Select iResult
    Case DialogResponse.POSITIVE
        Log("You selected the Positive button") '
    Case DialogResponse.NEGATIVE
        Log("You selected the Negative button")
    Case DialogResponse.CANCEL
        Log("You selected the Cancel button")
End Select
This works, independant of the button position displayed in the message box.

View attachment 70748

Attached, my test program.

Ah, OK, that is fine then. Thought the output was different for the numeric named buttons. Must be mistaken then and sorry
to cause confusion. Can't check now, but will do later.

RBS
 
Upvote 0
Top