S Steve-h Member Oct 30, 2021 #1 Using B4XPages I have a main page layout and a Page2 layout. I use “B4XPages.ShowPage ("Page2")” to move to page 2 and then “B4XPages.ShowPage ("MainPage")” to come back. As a result of some user input on page 2 I want to immediately change the visibility of some items and alter some text. How can I do that immediately without an event to respond to ? The only solution I have come up with is to set a timer running before leaving MainPage which occurs as an event when I return. Plainly there must be a better way. If I could somehow return directly to the sub from which I said “B4XPages.ShowPage ("Page2")” I would understand where I was.
Using B4XPages I have a main page layout and a Page2 layout. I use “B4XPages.ShowPage ("Page2")” to move to page 2 and then “B4XPages.ShowPage ("MainPage")” to come back. As a result of some user input on page 2 I want to immediately change the visibility of some items and alter some text. How can I do that immediately without an event to respond to ? The only solution I have come up with is to set a timer running before leaving MainPage which occurs as an event when I return. Plainly there must be a better way. If I could somehow return directly to the sub from which I said “B4XPages.ShowPage ("Page2")” I would understand where I was.
Erel B4X founder Staff member Licensed User Longtime User Oct 31, 2021 #2 I'm not sure that I understand, however I'm sure that a timer is not needed. Steve-h said: immediately change the visibility of some items and alter some text. How can I do that immediately without an event to respond to ? Click to expand... Code: B4XPages.ShowPage ("MainPage") B4XPage.MainPage.EditText17.Text = "whatever you like" Upvote 0
I'm not sure that I understand, however I'm sure that a timer is not needed. Steve-h said: immediately change the visibility of some items and alter some text. How can I do that immediately without an event to respond to ? Click to expand... Code: B4XPages.ShowPage ("MainPage") B4XPage.MainPage.EditText17.Text = "whatever you like"
B Brian Dean Well-Known Member Licensed User Longtime User Oct 31, 2021 #3 Just in case Erel has not quite understood your question, here is another suggestion. Why don't you use the MainPage_Appear event instead of the timer event? You can set a global switch in Page2 if the user makes a critical input and check the switch whenever the main page appears. Upvote 0
Just in case Erel has not quite understood your question, here is another suggestion. Why don't you use the MainPage_Appear event instead of the timer event? You can set a global switch in Page2 if the user makes a critical input and check the switch whenever the main page appears.
ilan Expert Licensed User Longtime User Oct 31, 2021 #4 you can call the sub that is on mainpage from page2 before you call "B4XPages.ShowPage ("MainPage")" so basically something like this: B4X: Private Sub Button1_Click B4XPages.GetPage("mainpage").As(B4XMainPage).loadData 'this sub is a Public sub in mainpage' B4XPages.ShowPage("MainPage")" End sub Upvote 0
you can call the sub that is on mainpage from page2 before you call "B4XPages.ShowPage ("MainPage")" so basically something like this: B4X: Private Sub Button1_Click B4XPages.GetPage("mainpage").As(B4XMainPage).loadData 'this sub is a Public sub in mainpage' B4XPages.ShowPage("MainPage")" End sub
S Steve-h Member Oct 31, 2021 #5 Thank you for the replies, the help is appreciated. I probably confused the issue by not explaining the question well enough. Ilan gets closest, as I understand it his solution allows me to call a PublicSub on MainPage where I can alter the visibility of some controls and text in labels before retuning and then calling main page itself. I will experiment with that approach. My confusion probably comes from not really understanding what I am doing when switching pages using :- B4XPages.ShowPage ("Page2") to call Page2 and B4XPages.ShowPage ("MainPage") to return to MainPage logging shows that it never seems to return to the sub on MainPage that called Page2 yet it does end up back on MainPage and seems to run the code on MainPage. Upvote 0
Thank you for the replies, the help is appreciated. I probably confused the issue by not explaining the question well enough. Ilan gets closest, as I understand it his solution allows me to call a PublicSub on MainPage where I can alter the visibility of some controls and text in labels before retuning and then calling main page itself. I will experiment with that approach. My confusion probably comes from not really understanding what I am doing when switching pages using :- B4XPages.ShowPage ("Page2") to call Page2 and B4XPages.ShowPage ("MainPage") to return to MainPage logging shows that it never seems to return to the sub on MainPage that called Page2 yet it does end up back on MainPage and seems to run the code on MainPage.
ilan Expert Licensed User Longtime User Nov 1, 2021 #6 Steve-h said: My confusion probably comes from not really understanding what I am doing when switching pages using :- B4XPages.ShowPage ("Page2") to call Page2 and B4XPages.ShowPage ("MainPage") to return to MainPage Click to expand... imaging you have 2 panels in your activity. 1 is called MainPage and the second is called Page2. by calling B4XPages.ShowPage ("Page2") you hide panel 1 that is the MainPage and show panel 2 that is Page 2 and the rest should be already clear Upvote 0
Steve-h said: My confusion probably comes from not really understanding what I am doing when switching pages using :- B4XPages.ShowPage ("Page2") to call Page2 and B4XPages.ShowPage ("MainPage") to return to MainPage Click to expand... imaging you have 2 panels in your activity. 1 is called MainPage and the second is called Page2. by calling B4XPages.ShowPage ("Page2") you hide panel 1 that is the MainPage and show panel 2 that is Page 2 and the rest should be already clear
ilan Expert Licensed User Longtime User Nov 1, 2021 #7 btw i prefer to use on mobile apps B4X: B4XPages.ShowPageAndRemovePreviousPages("mainpage") this will show the next page and remove the page that it was called from. Last edited: Nov 1, 2021 Upvote 0
btw i prefer to use on mobile apps B4X: B4XPages.ShowPageAndRemovePreviousPages("mainpage") this will show the next page and remove the page that it was called from.
S Steve-h Member Nov 1, 2021 #8 The explanation that calling the page simply hides the other was very helpful, I was thinking of it as calling a sub from which you had to return . Thank you. Upvote 0
The explanation that calling the page simply hides the other was very helpful, I was thinking of it as calling a sub from which you had to return . Thank you.
ilan Expert Licensed User Longtime User Nov 1, 2021 #9 Steve-h said: The explanation that calling the page simply hides the other was very helpful, I was thinking of it as calling a sub from which you had to return . Thank you. Click to expand... you may have a look at this example: https://www.b4x.com/android/forum/threads/b4x-xui-b4xpages-transition-class.135595/ Upvote 0
Steve-h said: The explanation that calling the page simply hides the other was very helpful, I was thinking of it as calling a sub from which you had to return . Thank you. Click to expand... you may have a look at this example: https://www.b4x.com/android/forum/threads/b4x-xui-b4xpages-transition-class.135595/