Coding a "Are you sure you want to exit?" prompt when exiting app GUI
18 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Emir Mulic
am 30 Apr. 2022
Kommentiert: Emir Mulic
am 30 Apr. 2022
I have coded an app for the first time which loads an image and allows you to adjust the colors and contrast. I would like to add a feature that when I press the "Exit" button, the app will ask the user "Are you sure you want to exit?" with two buttons "yes" or "no"
Right now I have a callback funtion called ExitPressed which runs app.delete();. I am assuming that what I have to code would be some function that checks if "yes" or "no" is pressed and then runs app.delete() is yes is pressed.
I am not sure how to get a window to pop up after the user presses Exit.
I appreciate any help possible.Thank you,
0 Kommentare
Akzeptierte Antwort
Riccardo Scorretti
am 30 Apr. 2022
You could modify the code of callback ExitPressed more or less in this way:
answer = questdlg('Are you sure you want to exit?', 'Confirm action', 'Yes', 'No', 'No');
if strcmpi(answer, 'Yes')
app.delete();
else
% Just do nothing
end
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!