Difference between CloseRequestFcn and DeleteFcn?
Mostrar comentarios más antiguos
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 comentarios
J. Alex Lee
el 3 de En. de 2023
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
el 3 de En. de 2023
Rik
el 3 de En. de 2023
You may consider moving the middle of your comment to the answer section.
J. Alex Lee
el 3 de En. de 2023
Editada: J. Alex Lee
el 3 de En. de 2023
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
el 4 de En. de 2023
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Scope Variables and Generate Names en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!