Dealing with screens can be tricky…
Screens are opened on top of whatever screen called the new screen. These screen openings will stack up and can get out of hand…
What I mean is that if you open your app (
Screen1), then open
Screen2 and then open
Screen3, these three screens are now layered on top of each other. If you close
Screen3, you will be taken back to
Screen2 because you never closed it. Closing
Screen2 would then take you back to
To keep your screens under control, you need to properly close them.
(see Ken’s reply post below)
When you open another screen, use the
open another screen with start value block. This will allow you to easily pass pass data to the new screen.
when btnScreen2.Click and
when btnScreen3.Click in “Screen 1 Blocks” below)
To access this data in the new screen, use the
get start value block.
when Screen2.Initialize in “Screen 2 Blocks” and
when Screen3.Initialize in “Screen 3 Blocks” below)
When you close a screen, use the
close screen with value block. This will allow you to easily pass data back to Screen1.
when btnScreen1.Click in both “Screen 2 Blocks” and “Screen 3 Blocks” below)
To access this data in Screen1, use the
when Screen1.OtherScreenClosed block. It has two variables attached.
when Screen1.OtherScreenClosed in “Screen 1 Blocks”)
Anyway, I’ve attached a simple example
.aia to show how to pass data between screens. (You should notice that I close the screens as I’m done with them, as I’ve mentioned above). There are three screens and each one has two textboxes for the “data” we want to pass. Type in some data and click a button. The resulting screen will show your data. In this new screen, feel free to change the original data in the textboxes and then click the button and your new data (or old data if you didn’t change it) will be passed back to Screen1.
Screen 1 Blocks
Screen 2 Blocks
Screen 3 Blocks
Screen_Passing.aia (6.6 KB)
Yes, you could just use a TinyDB to pass data between screens as well, however, if the data being passed doesn’t need to be preserved after the app is closed, it’s kind of a waste to use TinyDB when the built-in controls can already do this and without having to create the TinyDB file on the users device.
EDIT: Now that I’ve posted this, I’ve just noticed that adding the screen names to the data being passed is kind of redundant and not needed. Meh, it works and it’s been a long day for me. LOL