Hi,
This lib looks good. A good substitute for MsgBox/ToastMessageShow
I am just testing this lib to find out whether it will suit my requirements and while testing got stuck in the below given situation.
In an Alert Type "Success", usually there will not be a Cancel button, it will be just "OK" button that will be used to inform the user about the status of an action.
As this Lib works async way, we need to control the flow of the code accordingly.
When the Sweet Dialog is displayed, if the user press a back key, how do we trap that ? Or How do we execute something, if the user press the Back button
In my situation,when a SweetAlertDialog is displayed, even if the user press the back key, I need to do Activity.Finish
For Eg
Code:
Sub Globals
Dim SweetAD As SweetAlertDialog
End Sub
Sub SMTP_MessageSent(Success As Boolean)
SweetAD.Initialize("SweetAD")
SweetAD.AlertType = SweetAD.TypeSuccess
'As It is just an information to the user, I don't need the cancel button here.
'So I have used showCancelButton(False)
SweetAD.showCancelButton(False).showContentText(True).withConfirmText("OK").withContentText("Your request has been submitted.").withTitleText("Done").show
End Sub
Sub SweetAD_onConfirm ()
SweetAD.dismissWithAnimation
Activity.finish
End Sub
'The following sub will not get executed because SweetAD.showCancelButton(False) is used
' So the Activity does not get finished.
' If the user press back button, the following sub will not get executed
Sub SweetAD_onCancel ()
SweetAD.dismissWithAnimation
Activity.finish
End Sub
Is there a way in this lib, so that when a SweetAlert is displayed, if the user presses the BACK key, the onCancel Event of the lib is executed ?
Is there a way in this lib, so that the SweetAlert will get dismissed automatically after a specified time and the onCancel or onConfirm events gets triggered/fired
I understand that the following Sub can also be used to achieve what I wanted, but wanted to know whether any other elegant way is there in this library to trap the BACK key pressed considered as onCancel event.
Unfortunately, even the following code is failing, don't know why
Code:
Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event
If KeyCode = KeyCodes.KEYCODE_BACK Then
Activity.Finish
End If
Return True
End Sub
Any input will be appreciated.
Regards
Anser