iOS Question [B4XPages] B4XPage_CloseRequest different behavior between B4i and B4A

Alessandro71

Well-Known Member
Licensed User
Longtime User
I observed that, on B4A, B4XPage_CloseRequest gets called when the user taps the system "back" button.
On B4i, this does not happen when tapping the title bar "back" button.
How do I trap the back button on iOS or better, in a cross-platform way?
The B4XPage_Disappear seems unappropriated for my use case, since I'd like to continue running if the app is momentarily sent to back.
 
Solution
Try this:
B4X:
Private Sub B4XPage_Disappear
    Dim PageClosed As Boolean = Not(B4XPages.GetManager.mStackOfPageIds.Contains(B4XPages.GetPageId(Me)))
   
End Sub
I've tested it on B4i only.

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

Alessandro71

Well-Known Member
Licensed User
Longtime User
So, what's the correct callback to handle page closing in B4i?
B4XPage_Disappear is indeed called as result of "back" button, but is it also called when the app is simply put in background with the home button, but the page is not really closed: if I open it again, the page is still there
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Well, we often use B4XPage_CloseRequest to prevent the user from leaving the currently visible page; how do you do it with B4I?
 
Upvote 0

Alessandro71

Well-Known Member
Licensed User
Longtime User
There is no other event. What exactly are you trying to do?
Stopping a running Bluetooth communication that is closely related to the page that is being closed.
As a workaround, I'm using the Appear event of the underlying page to catch the closing of the previous one, but it seems convoluted to me.
 
Upvote 0

Alessandro71

Well-Known Member
Licensed User
Longtime User
I'll try enclosing it in #if B4i and calling CloseRequest, to have a single code path for both platforms
 
Upvote 0
Top