makis_best Well-Known Member Licensed User Longtime User Nov 11, 2020 #1 Hello With the Default method on Activity_Create we can check FirstTime run. With B4XPages how we can check FirstTime? Thank you. Last edited: Nov 11, 2020
Hello With the Default method on Activity_Create we can check FirstTime run. With B4XPages how we can check FirstTime? Thank you.
makis_best Well-Known Member Licensed User Longtime User Nov 11, 2020 #3 stari said: If FirstTime then Click to expand... I know about Default method I wander about B4XPages if FirstTime then not working. Upvote 0
stari said: If FirstTime then Click to expand... I know about Default method I wander about B4XPages if FirstTime then not working.
Sabotto Well-Known Member Licensed User Nov 11, 2020 #4 In B4XPages, the Create event is only triggered once, it's not like the Activities! Upvote 0
DonManfred Expert Licensed User Longtime User Nov 11, 2020 #5 As B4XPages never gets destroyed FirstTime = false never happen Upvote 0
makis_best Well-Known Member Licensed User Longtime User Nov 11, 2020 #6 So I need to find a trick to emulate FirstTime. Upvote 0
LucaMs Expert Licensed User Longtime User Nov 11, 2020 #7 Maybe he might need a "first time appeared". A private variable in the Class_Globals would be sufficient. B4X: Sub Class_Globals Private mFirstTimeAppeared As Boolean = True Private Sub B4XPage_Appear If mFirstTimeAppeared Then Else End If mFirstTimeAppeared = False End Sub Last edited: Nov 11, 2020 Upvote 0
Maybe he might need a "first time appeared". A private variable in the Class_Globals would be sufficient. B4X: Sub Class_Globals Private mFirstTimeAppeared As Boolean = True Private Sub B4XPage_Appear If mFirstTimeAppeared Then Else End If mFirstTimeAppeared = False End Sub
makis_best Well-Known Member Licensed User Longtime User Nov 11, 2020 #8 @LucaMs I try your idea using B4XPage_Appear and with B4XPage_Disappear but does not work. keep running the code I want to run for once. Upvote 0
@LucaMs I try your idea using B4XPage_Appear and with B4XPage_Disappear but does not work. keep running the code I want to run for once.
LucaMs Expert Licensed User Longtime User Nov 11, 2020 #9 makis_best said: @LucaMs I try your idea using B4XPage_Appear and with B4XPage_Disappear but does not work. keep running the code I want to run for once. Click to expand... I hope you haven't changed the value of mFirstTimeAppeared in the B4XPage_Disappear. It should work. Upvote 0
makis_best said: @LucaMs I try your idea using B4XPage_Appear and with B4XPage_Disappear but does not work. keep running the code I want to run for once. Click to expand... I hope you haven't changed the value of mFirstTimeAppeared in the B4XPage_Disappear. It should work.
LucaMs Expert Licensed User Longtime User Nov 11, 2020 #10 As you know FirstTime doesn't mean "first absolute time you run this app". Upvote 1
makis_best Well-Known Member Licensed User Longtime User Nov 11, 2020 #11 Correct... I just find it out... My mistake. Now Working fine. I mess around B4XPage_Appear and B4XPage_Disappear. Thank you all. Upvote 0
Correct... I just find it out... My mistake. Now Working fine. I mess around B4XPage_Appear and B4XPage_Disappear. Thank you all.
Erel B4X founder Staff member Licensed User Longtime User Nov 12, 2020 #12 Why such complicated solution?????? You almost never need to handle the Appear / Disappear events. Put the code in B4XPage_Created of B4XMainPage class. It runs once. Exactly like Activity_Create (FirstTime = True) Upvote 0
Why such complicated solution?????? You almost never need to handle the Appear / Disappear events. Put the code in B4XPage_Created of B4XMainPage class. It runs once. Exactly like Activity_Create (FirstTime = True)
Gianni M Well-Known Member Licensed User Longtime User Nov 12, 2020 #13 Erel said: Put the code in B4XPage_Created of B4XMainPage class. It runs once. Exactly like Activity_Create (FirstTime = True) Click to expand... the boss is always right ! Upvote 0
Erel said: Put the code in B4XPage_Created of B4XMainPage class. It runs once. Exactly like Activity_Create (FirstTime = True) Click to expand... the boss is always right !
LucaMs Expert Licensed User Longtime User Nov 12, 2020 #14 Erel said: Why such complicated solution?????? You almost never need to handle the Appear / Disappear events. Put the code in B4XPage_Created of B4XMainPage class. It runs once. Exactly like Activity_Create (FirstTime = True) Click to expand... giannimaione said: the boss is always right ! Click to expand... Not this time ? If you have to, like I have to, show something and work on something that includes resumable calls only once, I can't write this code in the Created routine, then I need "such a "complicated" solution" ? Upvote 0
Erel said: Why such complicated solution?????? You almost never need to handle the Appear / Disappear events. Put the code in B4XPage_Created of B4XMainPage class. It runs once. Exactly like Activity_Create (FirstTime = True) Click to expand... giannimaione said: the boss is always right ! Click to expand... Not this time ? If you have to, like I have to, show something and work on something that includes resumable calls only once, I can't write this code in the Created routine, then I need "such a "complicated" solution" ?
Erel B4X founder Staff member Licensed User Longtime User Nov 12, 2020 #15 LucaMs said: If you have to, like I have to, show something and work on something that includes resumable calls only once, I can't write this code in the Created routine, then I need "such a "complicated" solution" Click to expand... Why? Create a sub and call it from the created event. Upvote 0
LucaMs said: If you have to, like I have to, show something and work on something that includes resumable calls only once, I can't write this code in the Created routine, then I need "such a "complicated" solution" Click to expand... Why? Create a sub and call it from the created event.
LucaMs Expert Licensed User Longtime User Nov 12, 2020 #16 Erel said: Why? Create a sub and call it from the created event. Click to expand... Because the code to be executed requires Root has already been displayed. Upvote 0
Erel said: Why? Create a sub and call it from the created event. Click to expand... Because the code to be executed requires Root has already been displayed.
Erel B4X founder Staff member Licensed User Longtime User Nov 12, 2020 #17 Call it at the end of the Created event. You can also start the sub with Sleep(0) if you want to allow the layout to appear. Upvote 0
Call it at the end of the Created event. You can also start the sub with Sleep(0) if you want to allow the layout to appear.
makis_best Well-Known Member Licensed User Longtime User Nov 12, 2020 #18 Erel said: Why such complicated solution?????? You almost never need to handle the Appear / Disappear events. Put the code in B4XPage_Created of B4XMainPage class. It runs once. Exactly like Activity_Create (FirstTime = True) Click to expand... And how we check FirstTime = False? B4XPage_Created load only once not every time page show. Upvote 0
Erel said: Why such complicated solution?????? You almost never need to handle the Appear / Disappear events. Put the code in B4XPage_Created of B4XMainPage class. It runs once. Exactly like Activity_Create (FirstTime = True) Click to expand... And how we check FirstTime = False? B4XPage_Created load only once not every time page show.
Erel B4X founder Staff member Licensed User Longtime User Nov 12, 2020 #19 makis_best said: B4XPage_Created load only once not every time page show. Click to expand... And that is a very good thing. If you do want to do something when the page appears then use that event. In my experience, the Appear event, is used in many cases when developers try to imitate the complex activities behavior, and don't realize that you can directly access the page elements and do whatever you need immediately. The Appear event can be useful to enable timers for example. Upvote 0
makis_best said: B4XPage_Created load only once not every time page show. Click to expand... And that is a very good thing. If you do want to do something when the page appears then use that event. In my experience, the Appear event, is used in many cases when developers try to imitate the complex activities behavior, and don't realize that you can directly access the page elements and do whatever you need immediately. The Appear event can be useful to enable timers for example.
makis_best Well-Known Member Licensed User Longtime User Nov 12, 2020 #20 Ok... In my case I load a layout first time the page created and I load a second one when I get back to the that page. How else to do if not control B4XPage_Appear? Upvote 0
Ok... In my case I load a layout first time the page created and I load a second one when I get back to the that page. How else to do if not control B4XPage_Appear?