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

183 views (last 30 days)
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?

Accepted Answer

Adam Danz
Adam Danz on 12 Sep 2020
Edited: Stefanie Schwarz on 30 Jan 2024
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
  7 Comments

Sign in to comment.

More Answers (0)

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!