App Designer - confirm exit when application is closed from Windows bar

51 ビュー (過去 30 日間)
Mario Malic
Mario Malic 2020 年 9 月 12 日
コメント済み: Adam Danz 2025 年 4 月 29 日
Hi guys,
I have a simple question regarding App Designer.
Sometimes I accidentally click the close button which exits the application (obviously). Is there a way to implement the confirmation dialog?

採用された回答

Adam Danz
Adam Danz 2020 年 9 月 12 日
編集済み: Stefanie Schwarz 2024 年 1 月 30 日
Add a close request function to your app that requires confirmation.
1. From AppDesigner > Design View, right click the figure background, go down to "Callbacks", and select "Add CloseRequestFcn function callback".
2. A UIFigureCloseRequest() function will be added in Code View. Add this to the function where app.UIFigure is the handle to your app figure.
YN = uiconfirm(app.UIFigure,'Do you want to close the app?', 'Close request');
if strcmpi(YN,'OK')
delete(app)
end
  11 件のコメント
dpb
dpb 2025 年 4 月 26 日
Yeah, @Image Analyst, that's what I've done for the moment with further amplification in the other thread on the callbacks in the particular app being confounded by my prior actions, not knowing better at the time...
Adam Danz
Adam Danz 2025 年 4 月 29 日
This was such a great question that I wrote an article about it this morning.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeApp Building についてさらに検索

タグ

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by