Android Question [SOLVED] B4XPages - Really strange B4XPage_Created event

LucaMs

Expert
Licensed User
Longtime User
As you can see, B4XPage_Created of paglobby is executed (or, better, it seems to be executed):

1649142564383.png



This is the code of that event routine (paglobby B4XPage, of course):
1649142663149.png


Well, you also see that the log is not executed, and in fact only a blank white page appears.

The code that opens the page:
1649142991679.png



BTW, I noticed that the Appear event is triggered twice but not only in this project of mine, even in a very simple test project :oops:
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
I know that I can reproduce only the "Appear twice" "problem", since the main one never happened to me before.
The second, minor, problem occurs when you open a page and close the one from which you do it.

B4X:
Private Sub Button1_Click
    B4XPages.ShowPage("pagOne")
    B4XPages.ClosePage(Me)
End Sub

1649170106399.png
 

Attachments

  • AppearTest.zip
    14.3 KB · Views: 94
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
The second, minor, problem occurs when you open a page and close the one from which you do it.

B4X:
Private Sub Button1_Click
    B4XPages.ShowPage("pagOne")
    B4XPages.ClosePage(Me)
End Sub

View attachment 127533
... and this is what happens if you "swap" those two lines of code:

1649170713594.png


The Disappear event of mainpage fires twice (this shouldn't happen either)
 
Last edited:
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Since I am smarter than the son of a stone marten and a fox šŸ˜„, in the B4XMainPage I added that page (paglobby) to the B4XPages using AddPageAndCreate instead of AddPage.

Here is the result (i.e. not even in this way the B4XPage_Created event-routine is actually executed, the log I wrote as the first line of this routine is not executed):

1649180029941.png


Very soon, in 2033, I will be able to unravel this mystery!
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Since I am smarter than the son of a stone marten and a fox šŸ˜„, in the B4XMainPage I added that page (paglobby) to the B4XPages using AddPageAndCreate instead of AddPage.
2.gif


EDIT: pagLobby was initialized in B4XMainPage Initialize, when I created that animated gif; next I moved that initialization to B4XPage_Created but nothing changed.
 
Last edited:
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
EDIT: pagLobby was initialized in B4XMainPage Initialize, when I created that animated gif; next I moved that initialization to B4XPage_Created but nothing changed.
Finally I found the bug, doing what I wrote above: I realized that, instead, in the B4XMainPage Initialize I had initialized other pages but not that one.

I will definitely never make that mistake again, I will always write the Initialize right before the AddPage, but this type of error should have thrown an exception, the class was not initialized!


The anomaly of the double execution of the Appear or the Disappear (see attached project previously) is however a bug of B4XPages, I think.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
The anomaly of the double execution of the Appear or the Disappear (see attached project previously) is however a bug of B4XPages, I think.

1. Note that closing the non-top page is not supported on B4i.
2. If you want to show the next page and close the current one then it is better to call:
B4X:
B4XPages.ShowPageAndRemovePreviousPages("pagOne")
3. This is indeed a bug in B4XPages and it will be fixed in the next update.
 
Upvote 0
Top