Sergey_New Well-Known Member Licensed User Longtime User Feb 15, 2022 #1 I use a common function to open Activity2 from Activity1 with the required parameter. Activity1 B4X: function.openData("Activity2"),"setData", key) ' for other pages, the "setData" procedure will be different function B4X: Sub openData(CallBack As Object, fn As String, key As String) CallSubDelayed2 (CallBack, fn, key) End Sub Activity2 B4X: Sub setData(key) ' ... End Sub What is the correct way to do this in B4XPages for Page1 and Page2? My version: Page1 B4X: function.openData("Page2","setData", key, False) function B4X: Sub openData(IdPage As String, fn As String, key As String) B4XPages.ShowPage(IdPage) CallSubDelayed2 (B4XPages.GetPage(IdPage), fn, key) End Sub It is right?
I use a common function to open Activity2 from Activity1 with the required parameter. Activity1 B4X: function.openData("Activity2"),"setData", key) ' for other pages, the "setData" procedure will be different function B4X: Sub openData(CallBack As Object, fn As String, key As String) CallSubDelayed2 (CallBack, fn, key) End Sub Activity2 B4X: Sub setData(key) ' ... End Sub What is the correct way to do this in B4XPages for Page1 and Page2? My version: Page1 B4X: function.openData("Page2","setData", key, False) function B4X: Sub openData(IdPage As String, fn As String, key As String) B4XPages.ShowPage(IdPage) CallSubDelayed2 (B4XPages.GetPage(IdPage), fn, key) End Sub It is right?
Rubsanpe Active Member Licensed User Longtime User Feb 15, 2022 #2 Hi. There may be other options but you can directly call the function of the B4XPage through the page created in B4XPages.MainPage B4X: B4XPages.MainPage.<variable page definition>.setData(key) Rubén Upvote 0
Hi. There may be other options but you can directly call the function of the B4XPage through the page created in B4XPages.MainPage B4X: B4XPages.MainPage.<variable page definition>.setData(key) Rubén
Erel B4X founder Staff member Licensed User Longtime User Feb 15, 2022 #3 Code: 'in page2 Public ShowWithParameter (SomeParameter As Int) 'Do something with SomeParameter B4XPages.ShowPage("page2") End Sub page2.ShowWithParameter(15) Upvote 0
Code: 'in page2 Public ShowWithParameter (SomeParameter As Int) 'Do something with SomeParameter B4XPages.ShowPage("page2") End Sub page2.ShowWithParameter(15)
Sergey_New Well-Known Member Licensed User Longtime User Feb 15, 2022 #4 Erel, I don't understand. I need to use the openData procedure located in the function module. What code is needed in Page1, Page2 and function module? Upvote 0
Erel, I don't understand. I need to use the openData procedure located in the function module. What code is needed in Page1, Page2 and function module?
LucaMs Expert Licensed User Longtime User Feb 15, 2022 #5 Sergey_New said: It is right? Click to expand... Yes. Upvote 0
Andrew (Digitwell) Well-Known Member Licensed User Longtime User Feb 15, 2022 #7 Here is a modified 3 page example with passing parameter. Attachments parampass.zip parampass.zip 196.9 KB · Views: 256 Upvote 0
Sergey_New Well-Known Member Licensed User Longtime User Feb 15, 2022 #8 Andrew (Digitwell) said: Here is a modified 3 page example with passing parameter. Click to expand... Please tell me how to pass a parameter from Page3 to Page2 if Page2 is initialized in B4XMainPage. Upvote 0
Andrew (Digitwell) said: Here is a modified 3 page example with passing parameter. Click to expand... Please tell me how to pass a parameter from Page3 to Page2 if Page2 is initialized in B4XMainPage.
William Lancee Well-Known Member Licensed User Longtime User Feb 15, 2022 #9 In B4XPages the (1) Initialization, (2) Registration (Add or AddPageAndCreate) is usually done in B4XMainPage. When you want to show a page, it can be anywhere in your app. Creating a page is only done once, usually by loading some layout and running some setup code. If Show is called and the page has not yet been created it will do it before displaying the page - BUT only the first time. Creation is a one-time event. Show triggers "Sub B4XPage_Appear". It has no parameters (By design, since the parameter signature could vary from page to page.) If the page needs to be modified before being shown it should be done in "Sub B4XPage_Appear". If you want to pass parameters when showing a page, first set the values of Public variables in that page. This includes names of page specific functions that you can invoke with CallSub and CallSubDelayed. Last edited: Feb 15, 2022 Upvote 0
In B4XPages the (1) Initialization, (2) Registration (Add or AddPageAndCreate) is usually done in B4XMainPage. When you want to show a page, it can be anywhere in your app. Creating a page is only done once, usually by loading some layout and running some setup code. If Show is called and the page has not yet been created it will do it before displaying the page - BUT only the first time. Creation is a one-time event. Show triggers "Sub B4XPage_Appear". It has no parameters (By design, since the parameter signature could vary from page to page.) If the page needs to be modified before being shown it should be done in "Sub B4XPage_Appear". If you want to pass parameters when showing a page, first set the values of Public variables in that page. This includes names of page specific functions that you can invoke with CallSub and CallSubDelayed.
Sergey_New Well-Known Member Licensed User Longtime User Feb 15, 2022 #10 William Lancee, I read this. In the example from post #7, I ask you to change the opening of Page2 from Page3. Upvote 0
William Lancee, I read this. In the example from post #7, I ask you to change the opening of Page2 from Page3.
Andrew (Digitwell) Well-Known Member Licensed User Longtime User Feb 15, 2022 #11 In page3 defin B4X: Definition private page2 as Page2 ' somewhere in page 3, say a button click event Page2.Page2PassParam("From page 3") Upvote 0
In page3 defin B4X: Definition private page2 as Page2 ' somewhere in page 3, say a button click event Page2.Page2PassParam("From page 3")
Sergey_New Well-Known Member Licensed User Longtime User Feb 15, 2022 #12 Andrew (Digitwell) said: In page3 Click to expand... Writes that Page2 is not initialized. Could you do it in the example from the post #7? Upvote 0
Andrew (Digitwell) said: In page3 Click to expand... Writes that Page2 is not initialized. Could you do it in the example from the post #7?
Andrew (Digitwell) Well-Known Member Licensed User Longtime User Feb 15, 2022 #13 Try this. Added a button in Page 2. In page 3, B4X: Private Sub btnPage2_Click B4XPages.MainPage.page2.Page2PassParam("From Page 3") End Sub Attachments parampass.zip parampass.zip 197 KB · Views: 261 Upvote 1
Try this. Added a button in Page 2. In page 3, B4X: Private Sub btnPage2_Click B4XPages.MainPage.page2.Page2PassParam("From Page 3") End Sub
Sergey_New Well-Known Member Licensed User Longtime User Feb 15, 2022 #14 Andrew (Digitwell) is what I wanted. Thanks a lot! Upvote 0