Adding a Universal MessageBox
A universal MessageBox is a messagebox that is created once in the app and is available in the complete app from any page.
For this to be possible, the messagebox should be created in the pgIndex and then can be called anywhere from the app.
One is able to (a) raise and alert, (b) raise a confirmation and (c) raise a prompt.
Reproduction
Open the baselayout and drop a VMsgBox inside the VApp component. The msgBox shoul be placed insid VApp and not anywhere where.
Ensure that you check the App Dialog property:
Generate members inside pgIndex so that it will be usable for the app. Ensure you include OK_click and CANCEL_click for the new msgbox.
These two subs should have ONLY the lines of code adde and NOTHING else. In my example, the dialog name is "appdialog"
Private Sub appdialog_Ok_Click (e As BANanoEvent)
vuetify.ActivePageOkResponse
End Sub
Private Sub appdialog_Cancel_click (e As BANanoEvent)
vuetify.ActivePageCancelResponse
End Sub
When ok / cancel is clicked, these subs locate specific subs on those pages. These are
OkResponse and
CancelResponse
On any page that needs to call the universal message box for alerts, prompts, confirmation, you need to
1. Add the OkResponse and CancelResponse callbacks.
In Initialize of the page, before AddRoute, add these 2 lines
page.AddMethod("OkResponse", Null)
page.AddMethod("CancelResponse", Null)
This registers the methods for use.
2. Declare the callbacks.
'dialog clicked in pgIndex
private Sub OkResponse
'get the response
vuetify.HideDialog
Dim lastProcess As String = vuetify.Process
Dim enteredValue As String = vuetify.GetResponseValue
vuetify.ShowSwalSuccess("App Ok: " & lastProcess & " : " & enteredValue)
End Sub
'dialog clicke in pgIndex
private Sub CancelResponse
vuetify.hidedialog
Dim lastProcess As String = vuetify.Process
vuetify.ShowSwalError("App Cancel: " & lastProcess)
End Sub
We need the .
Process and .
GetResponseValue (for prompts) here.
Calling the messagebox
Showing an Alert
Private Sub btnAlert_Click (e As BANanoEvent)
vuetify.Alert("app_alert", "Alert", "This is a app alert", "Great!")
End Sub
This will show the alert and send the process app_alert to OkResponse, use Vuetify.Process to find out which process was calling the MessageBox.
Showing a Confirmation
For a confirmation, depending on what you have clicked, the response can be to OkResponse (when ok is clicked) or CancelResponse (when cancel is clicked)
Private Sub btnConfirm_Click (e As BANanoEvent)
vuetify.Confirm("app_confirm", "Confirm Delete", "Are you sure you want to delete this?", "Yes", "No")
End Sub
So CancelResponse will trap the Cancel click.
Getting content from a Prompt
Private Sub btnInput_Click (e As BANanoEvent)
vuetify.Prompt("app_prompt", "First Name", "What is your first name", "", "", "Mashy", "Ok", "Cancel")
End Sub
When ok is clicked, what the user enters is returne by vuetify.GetResponsValue
This has been added to the kitchen sinks Whats New Section.