Difference between CloseRequestFcn and DeleteFcn?
이전 댓글 표시
Hello, I use the 'CloseRequectFcn' Figure property in my GUI design to hande "program shutdown"-related tasks, like closing files and windows, stopping cameras, etc. Recently, I took over a project where the previous author used 'DeleteFcn' for this purpose. My question is, what is the correct way to use these two functions? Is there a case where one is better than the other? Is one "more correct" for handling program exit? The documentation doesn't seem to give a clear answer. Thanks!
댓글 수: 5
J. Alex Lee
2023년 1월 3일
maybe just use both and redirect to a common shutdown function; catch the case where someone wants to shut down the app by deleting the handle to it as well as close()-ing it, or using the GUI to close
M. A. Hopcroft
2023년 1월 3일
Rik
2023년 1월 3일
You may consider moving the middle of your comment to the answer section.
J. Alex Lee
2023년 1월 3일
편집: J. Alex Lee
2023년 1월 3일
apparently you don't even need to call delete inside the deleteFcn for the deletion to happen...
f = figure("DeleteFcn",@(o,e)disp("called delete"))
delete(f)
will still close the figure.
So I would say make your closerequestfcn just call your deletefcn callback, and do everything in there.
M. A. Hopcroft
2023년 1월 4일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Scope Variables and Generate Names에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!