How check in App Designer if a secondary App is already open?

10 ビュー (過去 30 日間)
Eros
Eros 2024 年 6 月 27 日
コメント済み: Eros 2024 年 6 月 28 日
Hello,
in App Designer I have two Apps: a MainApp and a SecondaryApp.
I set a PushButton1 in the MainApp that calls the SecondaryApp, opens it, here I set the parameters I want and, by pressing a PushButton2 (in the secondary app), I close the SecondaryApp and send the chosen parameters to the MainApp.
How can I check inside MainApp if the SecondaryApp is already open and close it?
Because now I risk opening the SecondaryApp multiple times.
The problem is that when I work in the MainApp I have no visibility on the secondary and, furthermore, I cannot simply disable the PushButton1 with which I call the secondary in the MainApp because the button would remain deactivated when I manually close the SecondaryApp window without using the PushButton2 for sending parameters.
Thanks

採用された回答

Eros
Eros 2024 年 6 月 28 日
Solved! searching through the settings, I discovered that it is possible to set directly in App Designer the unique instance for each single App: this therefore allows you not to open the same App multiple times, but to have only one App (Secondary App, in my case) open.
Exactly what I was looking for, simply by enabling a check box in settings.
Here is what to do for those who find themselves in the same problem as me:

その他の回答 (1 件)

Matlab Pro
Matlab Pro 2024 年 6 月 27 日
Here is a simple function I have created a simple function that can help you
function hApp = getapp(appName)
hApp = [];
hFigs = findall(0,'type','figure');
if ~isempty(hFigs)
idx = ismember({hFigs.Name},appName);
hApp = hFigs(idx);
end
You call it with an app name (as apeared on teh main figure.
If it is NOT up - it will renturn an empty handle
Otherwise - it will return a handle to this app
Examples:
hApp = getapp('SecondaryApp')
or...
hApp = getapp('MATLAB App')
hApp =
Figure (MATLAB App) with properties:
Number: []
Name: 'MATLAB App'
Color: [0.9400 0.9400 0.9400]
Position: [100 100 640 480]
Units: 'pixels'
Hope this helps..
  2 件のコメント
Matlab Pro
Matlab Pro 2024 年 6 月 27 日
well. I have uploaded a little improved version to the XExchange server
Eros
Eros 2024 年 6 月 28 日
Hello, thank you very much for the good trick.
However, searching through the settings, I discovered that it is possible to set directly in App Designer the unique instance for each single App: this therefore allows you not to open the same App multiple times, but to have only one App (Secondary App, in my case) open.
Exactly what I was looking for, simply by enabling a check box in settings.
I added a comment with the screenshot of the setting

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by