B4J Question ShowToastWithReturns

David Elkington

Active Member
Licensed User
Longtime User
Hi All,

I am using ABMATERIAL to design a web app, but I struggle to find good code examples for some reason, I never seemed to have this issue with B4A. I was wondering if someone had a code example for Toast, I want to quickly use it to confirm an action with Yes, No....

This is what I have, but I don't know how to trap the result...

code

page.ShowToastWithReturns("tConfirmEmail","ToastRed","Send email",10000, Array As String("Yes","No"),Array As String("Yes","No"),True)

/code
 

Harris

Expert
Licensed User
Longtime User
Also Try Msgbox2:

B4X:
    page.Msgbox2("DOWNL","Download the Android Mobile App","Get Device Application","Download","Cancel",False,ABM.MSGBOX_TYPE_QUESTION,False,ABM.MSGBOX_POS_CENTER_CENTER,"")



' then the result code....


Sub page_MsgboxResult(returnName As String, result As String)

 Dim dirf As ABMLabel = page.Component("dirf")


 If result = ABM.MSGBOX_RESULT_OK Then
    Log(" OK was pressed   Return name "&returnName&"  result: "&result)   
 End If

  Select Case returnName
     Case "DOWNL"
        Log(" what is result: "&result)
          Select Case result
           
             Case "abmok" 
               
               Dim add As String = "../../apks/tinspect.apk"
               ws.Eval("window.location = arguments[0]", Array As Object(add))   
               ws.Flush
               Log("tried to download")

        End Select

    Case "ECMH"

        Select Case result

            Case "abmok"
                If dirname.Length > 2 Then
                    Main.histecmFolder = dirname
                    dirf.Text = "HISTORIC ECM Folder: "&CRLF& Main.histecmFolder
                    dirf.Refresh
                Else
                    page.Msgbox("ms1","ERROR!!!","No History Record Selected!","Return",False,ABM.MSGBOX_POS_CENTER_CENTER,"")
                End If
           
                   
        End Select


    Case "ECMC"

        Select Case result

            Case "abmok"
            Main.histecmFolder = Main.ecmFolder   
            dirf.Text = "Current ECM Folder: "&CRLF&Main.histecmFolder   
            dirf.Refresh
                   
        End Select

       
 End Select
     
End Sub
 
Upvote 0

David Elkington

Active Member
Licensed User
Longtime User
Many thanks for your replies. I wanted to use toast so that it does not disrupt the workflow, so it would disappear in 5 seconds if they did not mean to do the action. Mr AB replied to me and it works quite nicely now and kinda stays out of your face.
 
Upvote 0

David Elkington

Active Member
Licensed User
Longtime User
He also gave me a good trick as below...

I good thing to do is putting log(EventName) in the ParseEvent() method. It will quickly show you what method it is expecting (e.g. for your ShowToastWithReturn issue).

Harris has put up a good getting started tutorial (for dummies) for which I'm very grateful.
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
Mr AB replied to me and it works quite nicely now and kinda stays out of your face.
If you have an example of this, I will add it to the tutorial, for future reference when others encounter the same difficulty.

Thanks
 
Upvote 0

David Elkington

Active Member
Licensed User
Longtime User
Basically it was just like this...

Call the toast...

If bolToastShowing = False Then ' I use this to stop the reoccurrence

page.ShowToastWithReturns("tConfirmEmail","ToastPurpleC","Send email:",5000, Array As String("Click to Confirm"),Array As String("Yes"),False)
bolToastShowing = True

End If


Sub Page_ToastClicked(toastID As String, Action As String)

If toastID="tConfirmEmail" Then
If Action="Yes" Then

Do your email action

page.showToast("tDone","ToastGreen","Email has been queued",2000,False)
bolToastShowing=False
End If
End If
 
Upvote 0
Top