creating apps communicate each other with app designer

80 views (last 30 days)
Ercument Kalkan
Ercument Kalkan on 15 May 2019
Edited: Adam Danz on 2 Feb 2021
How to share a value in a field of an app to another? For example i am trying to get the number in a field to the other app by pushing a button. It is said that the properties would help about that but i could not manage to use them properly.

Answers (1)

Adam Danz
Adam Danz on 27 Apr 2020
Edited: Adam Danz on 2 Feb 2021
The goal is to get access to the app's handle. Once you have access to the app's handle, you have access to anything within the app. Also see Matlab's documentation on multi-window apps.
Here are two ways to get the app's handle.
Evoke app #2 within app #1.
Within the startupFcn or within any callback function of an app, open the second app and store its handle.
app2Handle = app2; % where "app2" is the (poor) name of the 2nd app.
For more info & demos on this method
Find the handle to an app that's already opened
The HandleVisibility of UIFigures is set to off by default which makes it a bit more difficult to find a UIFigure (or app) handle. The code below finds all figure handles and then isolates the handle that belongs to your app.
% get handles to *all* figures
allfigs = findall(0,'Type', 'figure');
% isolate the app's handle
app2Handle = findall(allfigs, 'Name', 'MyApp'); % MyApp is the App's fig name*
Importantly, "MyApp" in the example above is the name of the app's figure (not necessarily the name of the app). It requires a unique name that can be distinguished from any other figure name.
To name your app's figure,
  1. open your app in AppDesigner and go to Design View
  2. Select the figure background or the top-most component in the Component Browser
  3. From the Inspector list of properties, scroll down to "Identifiers"
  4. use the "Name" property to name your app's figure. This name will appear in your new app figure.
Make the app handle available from anywhere within the app.
To make the app #2 handle available from anywhere within the app, set the variable containing the app handle as a private or public property by following these instructions from the documentation.

Products


Release

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!