If the user closes the page but there are still unsaved changes, I would like to show the user a warning and give them the option to cancel the action.
How does this work with B4XPages?
Private Sub B4XPage_CloseRequest As ResumableSub
Dim sf As Object = xui.Msgbox2Async("Do you really want to close?", "Title", "Yes", "Cancel", "No", Null)
Wait For (sf) Msgbox_Result (Result As Int)
If Result <> xui.DialogResponse_Positive Then
Return True
End If
Return False
End Sub
B4XPages is a library that serves two purposes: 1. Make it simple to develop B4A apps by solving almost all of the challenges involved with Android complex activities life cycle. B4XPages makes B4A behave more similar to B4J and B4i where the new "B4XPage" element is a regular object that is...
I've been able to simulate the page close event on B4i with the following trick.
You can check if this allows the LucaMS suggestion to work for you
B4X:
Sub B4XPages_Disappear
#if B4i
Dim PageClosed As Boolean = Not(B4XPages.GetManager.mStackOfPageIds.Contains(B4XPages.GetPageId(Me)))
If PageClosed Then
B4XPage_CloseRequest
End If
#end if
End Sub
I don't have B4i, so what I'm about to write could be completely wrong.
I suppose there is a close event in the Main of a B4i project. In this, you should detect which B4XPage is currently displayed, call one of its methods asking the user (...) and possibly show another B4XPage.
the Disappear event is triggered _after_ the page has been closed, so it's not on the stack anymore.
maybe not exactly what Alexander was searching, but it could be starting point
Are you sure? Because the purpose of the event is to allow you to perform some operation, so theoretically the page should only be deleted from the stack at the "End Sub".
You can prevent the user from closing the page, but if this option is enabled then you aren't expected to cancel it. The user can close the page with a swipe.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.