Sharing values between 2 app designer apps
16 views (last 30 days)
Show older comments
Hello guys, I'm trying to create 2 mlapp to pass data from one to another.
Basically I need to read value of a drop down menu which is present in App2 and then send this value (for example pressing a button) to an uitable in App1.
I have read many guides about this argument, even official one, but I don't understand how to write my code.
I hope someone could help me. Thanks
0 Comments
Answers (1)
Jon
on 13 Nov 2023
Edited: Jon
on 13 Nov 2023
I have attached two MATLAB Apps that provide a highly simplified example of how to do what I think you are asking.
Please save these two files to your working directory.
To run the example type main on the command line.
This will open main.mlapp, and the startup function in main.mlapp will open helper.mlapp. (The second app may be right behind the other one so move the windows around to see both)
On the helper app, pick an animal name from the drop down, and then press the button to send the data to the main app.
Look at the startup function for main, you will see it calls helper, and passes a reference to itself to helper so that helper can send data back. A property, called mainApp is defined in help.mlapp to store this reference. When help.mlapp opens, it's start up function saves this reference to the property app.mainApp so that it can access it when it needs it.
The callback for the send push button then get the data from the dropdown assigning it to the local variable, selection, and then sends the data to the main app using app.mainApp.animalTable.Data = {selection}
2 Comments
Jon
on 13 Nov 2023
By the way, app designer also supports having multiple tabs within the same app. Could you design your application to just use separate tabs instead of having multiple apps. If so that would be a lot simpler, and everything would be self contained in one app.
Jon
on 15 Nov 2023
Did this answer your question? Did you have any further questions. If this answered your question please accept the answer so that others with similar issues will know an answer is available
See Also
Categories
Find more on Develop Apps Using App Designer in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!