How do I make an App written in App Designer Modal?

15 ビュー (過去 30 日間)
Steve Page
Steve Page 2018 年 6 月 8 日
回答済み: Itshak 2024 年 1 月 30 日
I want to call an App written in App Designer from another App written in App Designer. While the called App is running I do not want the user to be able to interact with the calling App. How do I make the called App Modal? The WindowsStyle property of the class matlab.ui.Figure is not accessible.

回答 (4 件)

Chris Portal
Chris Portal 2018 年 6 月 10 日
If you're using 18a or later, you can try using UIPROGRESSDLG to create an indeterminate progress bar while the secondary app is open. It's not the same modal behavior WindowStyle would give, but it achieves the same task:
  1 件のコメント
CHAI YUAN
CHAI YUAN 2019 年 3 月 28 日
編集済み: CHAI YUAN 2019 年 3 月 29 日
I thought of a suitable method

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


CHAI YUAN
CHAI YUAN 2019 年 3 月 29 日
編集済み: CHAI YUAN 2019 年 3 月 29 日
Class 'test1' is the parent window
Class 'test2' is the child window
test1:function ButtonPushed(app, event)
d = uiprogressdlg(app.test1UIFigure,'Message','Child window detected.');
app.test2Obj = test2;
% (Write your original code here.)
while 1
if exist([cd,'\CYcloneX'],'dir')
break;
end
pause(0.01)
end
close(d);
rmdir([cd,'\CYcloneX'],'s')
test2:function test2UIFigureCloseRequest(app, event)
mkdir([cd,'\CYcloneX'])
delete(app)

Itshak
Itshak 2024 年 1 月 30 日
For anyone still looking for a solution in 2024. The component browser panel has an option to set the UIFigure Window Style to modal. Upon setting this value if a secondary app is launched from a primary modal app, the primary modal app will be uninteractable as long as the second one is open.

Michael Kaiser
Michael Kaiser 2021 年 3 月 26 日
The MATLAB function waitfor() may be used.
For example, here is a button pushed callback in an AppDesigner UI that calls another AppDesigner UI to view and modify settings (app.SPSettings):
% Button pushed function: SigProcSettingsButton
function SigProcSettingsButtonPushed(app, event)
% Save a copy of the current signal processing settings
SPSOld = app.SPSettings;
% Invoke AppDesigner UI to observe and modify settings
hDlg = EditVWW2SigProcParams(app.SPSettings);
% Wait for App Designer UI to close (modal behavior)
waitfor(hDlg);
% If settings have been changed, update them in the the engine
if ~isequal(app.SPSettings, SPSOld)
app.RTDBE.UpdateSPSettings(app.SPSettings);
end
end
Hope this helps!

カテゴリ

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