W WhiteWizard Member Licensed User Mar 16, 2021 #1 I'm trying to pass some parameters between two B4Xpages, there's some example from Erel where you define a Sub in the destination page and calls its before invoke the Showpage method, however this works only from the MainPage, if you are executing something in the Page2 for ex., and want to call a Sub on the Page3, you have no access to the Page3 methods. Putting some variables in the Main module is an ugly solution.
I'm trying to pass some parameters between two B4Xpages, there's some example from Erel where you define a Sub in the destination page and calls its before invoke the Showpage method, however this works only from the MainPage, if you are executing something in the Page2 for ex., and want to call a Sub on the Page3, you have no access to the Page3 methods. Putting some variables in the Main module is an ugly solution.
LucaMs Expert Licensed User Longtime User Mar 16, 2021 #2 It is a good practice to declare pages in the B4XMainPage Class_Globals as public. This way you can access them from anywhere (and do it what you need in this case). Upvote 0
It is a good practice to declare pages in the B4XMainPage Class_Globals as public. This way you can access them from anywhere (and do it what you need in this case).
Peter Simpson Expert Licensed User Longtime User Mar 16, 2021 #3 You can declare Public variables (V1) in absolutely any B4XPage (P2) and access that variable from any other B4XPage (P3) as long as you declare P2 in P3, then you can simply do something like P2.V1. Not a problem... Upvote 0
You can declare Public variables (V1) in absolutely any B4XPage (P2) and access that variable from any other B4XPage (P3) as long as you declare P2 in P3, then you can simply do something like P2.V1. Not a problem...
W WhiteWizard Member Licensed User Mar 16, 2021 #4 I've tried it but there's something that eludes my mind (in B4A): B4XMainPage: Code: Sub Class_Globals Private Root As B4XView 'ignore Private xui As XUI 'ignore Public txtUser As B4XFloatTextField Private btnLogin As B4XView Public Page2 As B4XPage2 Public Page3 As B4XPage3 Public PageIndicaciones As B4XPageIndicaciones Public PageFormIndicaciones As B4XPageFormIndicaciones Public PageFormIndicacionesMed As B4XPageFormIndicacionesMed Private txtPassword As B4XFloatTextField Private txtServerConfig As B4XFloatTextField Private txtExtServerConfig As B4XFloatTextField Private B4XLoadingIndicator1 As B4XLoadingIndicator Private LError As Label Public TransitionDuration As Int End Sub How do I access those instances?, if I'm inside B4XPage3 for example, I write "B4XMainPage." , "MainPage." , there's no way to access those members, I got no scope in B4A. Upvote 0
I've tried it but there's something that eludes my mind (in B4A): B4XMainPage: Code: Sub Class_Globals Private Root As B4XView 'ignore Private xui As XUI 'ignore Public txtUser As B4XFloatTextField Private btnLogin As B4XView Public Page2 As B4XPage2 Public Page3 As B4XPage3 Public PageIndicaciones As B4XPageIndicaciones Public PageFormIndicaciones As B4XPageFormIndicaciones Public PageFormIndicacionesMed As B4XPageFormIndicacionesMed Private txtPassword As B4XFloatTextField Private txtServerConfig As B4XFloatTextField Private txtExtServerConfig As B4XFloatTextField Private B4XLoadingIndicator1 As B4XLoadingIndicator Private LError As Label Public TransitionDuration As Int End Sub How do I access those instances?, if I'm inside B4XPage3 for example, I write "B4XMainPage." , "MainPage." , there's no way to access those members, I got no scope in B4A.
W WhiteWizard Member Licensed User Mar 16, 2021 #5 Peter Simpson said: You can declare Public variables (V1) in absolutely any B4XPage (P2) and access that variable from any other B4XPage (P3) as long as you declare P2 in P3, then you can simply do something like P2.V1. Not a problem... Click to expand... But if I declare one instance of B4XPage3 inside B4XPage2, and then set some public variables in B4XPage3, then invoke B4XPages.Show("Page3"), is the same class instance?, Upvote 0
Peter Simpson said: You can declare Public variables (V1) in absolutely any B4XPage (P2) and access that variable from any other B4XPage (P3) as long as you declare P2 in P3, then you can simply do something like P2.V1. Not a problem... Click to expand... But if I declare one instance of B4XPage3 inside B4XPage2, and then set some public variables in B4XPage3, then invoke B4XPages.Show("Page3"), is the same class instance?,
LucaMs Expert Licensed User Longtime User Mar 16, 2021 #6 WhiteWizard said: How do I access those instances?, if I'm inside B4XPage3 for example, I write "B4XMainPage." , "MainPage." , there's no way to access those members, I got no scope in B4A. Click to expand... WhiteWizard said: Public Page2 As B4XPage2 Public Page3 As B4XPage3 Public PageIndicaciones As B4XPageIndicaciones Public PageFormIndicaciones As B4XPageFormIndicaciones Public PageFormIndicacionesMed As B4XPageFormIndicacionesMed Click to expand... All those pages will be accessible (obviously their declaration is not enough, you will also have to initialize them and add them to the B4XPages, so writing B4XPages.AddPage("Page2", Page2) or B4XPages.AddPage("Page2ID", Page2)). To access: B4XPages.MainPage.Page2.YourSub Last edited: Mar 16, 2021 Upvote 0
WhiteWizard said: How do I access those instances?, if I'm inside B4XPage3 for example, I write "B4XMainPage." , "MainPage." , there's no way to access those members, I got no scope in B4A. Click to expand... WhiteWizard said: Public Page2 As B4XPage2 Public Page3 As B4XPage3 Public PageIndicaciones As B4XPageIndicaciones Public PageFormIndicaciones As B4XPageFormIndicaciones Public PageFormIndicacionesMed As B4XPageFormIndicacionesMed Click to expand... All those pages will be accessible (obviously their declaration is not enough, you will also have to initialize them and add them to the B4XPages, so writing B4XPages.AddPage("Page2", Page2) or B4XPages.AddPage("Page2ID", Page2)). To access: B4XPages.MainPage.Page2.YourSub
W WhiteWizard Member Licensed User Mar 16, 2021 #7 Thank you LucaMs! B4X: B4XPages.MainPage.Page2.YourSub Upvote 0
aeric Expert Licensed User Longtime User Mar 17, 2021 #8 [B4X] B4XPages - Cross platform and simple framework for managing multiple pages 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... www.b4x.com Another way is to use GetPage. Point #9 in tutorial. B4X: Page3 = B4XPages.GetPage("Page 3") Page3.Button1.Text = "abc" Last edited: Mar 17, 2021 Upvote 0
[B4X] B4XPages - Cross platform and simple framework for managing multiple pages 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... www.b4x.com Another way is to use GetPage. Point #9 in tutorial. B4X: Page3 = B4XPages.GetPage("Page 3") Page3.Button1.Text = "abc"