B4J Question On closing xui.Msgbox2Async without response

SeaBee

Member
Licensed User
First, the code, which I am using to select specific items from a B4XTable:-

B4X:
Sub B4xTable1_CellClicked(ColumnID As String, RowId As Long)
    
    Dim RowData As Map = B4XTable1.GetRow(RowId)
    Dim cell As String = RowData.Get(ColumnID)
    Log(cell)
    Log("Number = " & Round(RowData.GetValueAt(0)) & " & Name = " &  RowData.GetValueAt(1))

    Dim MB2A As Object = xui.Msgbox2Async("Number = " & Round(RowData.GetValueAt(0)) & " & Name = " &  RowData.GetValueAt(1),"Selected Item", "Add", "Done", "Discard", Null)
        
    Wait For (MB2A) MsgBox_Result (Result As Int)
        
    If Result = xui.DialogResponse_Positive Then
        Log( "Positive - Add")
    Else if  Result = xui.DialogResponse_Negative Then
        Log("Negative - Discard")
    Else if Result = xui.DialogResponse_Cancel Then
        Log("Cancel - Done")
    End If
        
End Sub

I want to trap if the user clicks the close button on the message box without making a selection. There may be no way, but in any event I have not been able to find one.
My second question is if the user just closes on that button, what happens to the Sub with the Wait For - just it just sit there waiting until the application closes?
 

SeaBee

Member
Licensed User
Many "code smells": https://www.b4x.com/android/forum/threads/116651/#content


A1: It is the same as clicking on the cancel button.
A2: It is the same as clicking on the cancel button.
Thanks very much for your rapid response. I shall have to do some thinking, because my plan was to use the Done button to process the collected selections. The actual displayed message was to include some additional data to assist in the Accept or Add decision, so I had hoped to use the Windows Close button as a Cancel without doing the processing of the list of selections.

Oh well - back to the drawing board!
 
Upvote 0

SeaBee

Member
Licensed User
Many thanks, again, for the fast answer. I'll look at it straight away. It looks to be more elegant than than throwing up an xui.MsgboxAsync to find out what the user wanted!
 
Upvote 0
Top