create a tab which appear before closing the GUI

How to create a tab which appear when i close the GUI to ask whether i want to export if i have not done and if its done its just close?

답변 (2개)

Jiri Hajek
Jiri Hajek 2022년 10월 10일

0 개 추천

You have to create a UIFigureCloseRequest callback, which is easily done in AppDesigner by a right click on the app.UIFigure in Component Browser.
Then, in the callback, use a.uiconfirm functiion, which gives two alternative answers (OK or Cancel). In an if-else block, you can manage the options you need do perform. You can close the app by the command delete(app).

댓글 수: 5

PA
PA 2022년 10월 10일
How can i create a UIfigureCLose request callback in GUI without Appdesigner through programm
This is not a way I'd recommend and if you have access to a recent release of MATLAB, AppDesigner is definitely the way to go...
It is possible to do programmatically, but you have to study the documentation in more depth. You may find the details here: https://www.mathworks.com/help/matlab/creating_guis/write-callbacks-for-apps-created-programmatically.html...
PA
PA 2022년 10월 10일
Thank you
PA
PA 2022년 10월 10일
how to create a check variable inside theclosed figure call back function :1 if its save, 0 if save not done
selection = uiconfirm(app.UIFigure, 'Do you really want to close the Project without Saving?',...
' Close Request','Options',{'Save','Donot Save','Cancel'});
switch selection
case'Save'
if x ==1
x= save is done;
elseif x==0
x = save is not done
delete (app)
case'Cancel'
return
end
end

댓글을 달려면 로그인하십시오.

Allen
Allen 2022년 10월 10일
@PA, I typically use something similar to the following.
qstr = "Do you really want to close the Project without Saving?";
qans = uiconfirm(app.UIFigure,qstr,"Close Request", ...
"Options",["Save","Don't Save","Cancel"], ...
"DefaultOption",1,"CancelOption",3);
if strcmp(qans,"Canel")
return
elseif strcmp(qans,"Save")
% I typically have a save function assign to a push button callback
% within my App and call it directly from here.
SaveButtonPushed(app,event)
% You can also directly insert any save functions that work for your
% data type.
% save(...)
end
delete(app)

카테고리

도움말 센터File Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

태그

질문:

PA
2022년 10월 10일

답변:

2022년 10월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by