How to hide a figure instead of deleting it?
13 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Chaitanya Jha
am 18 Mär. 2019
Kommentiert: Adam
am 18 Mär. 2019
Hi,
Is there any way I can change the DeleteFcn of a figure to not delete the figure but only make it invisible?
2 Kommentare
Geoff Hayes
am 18 Mär. 2019
Chaitanya - can you describe the use case for this? Are you closing a GUI (figure) that you wish to hide rather than delete? Or is there a figure (with axes or whatever) that you are "closing"? Please clarify.
Akzeptierte Antwort
Adam
am 18 Mär. 2019
Bearbeitet: Adam
am 18 Mär. 2019
If you over-ride the CloseRequestFcn you can have it do whatever you tell it. In general you should always have this function call delete on the figure if you over-ride it because that is expected behaviour and if you don't the figure will not get deleted.
So if you create a CloseRequestFcn that just does something else and does not delete the figure than it will stay alive and you can switch its 'Visible' property off and do whatever else you wish.
I do this for docking and undocking panels in one of my workflows. I have a panel that is undockable and, because it is part of the workflow I don't want the user to simply be able to delete the panel when it is an undocked figure I program the CloseRequestFcn to redock it in the main figure.
The interaction between DeleteFcn, CloseRequestFcn and one or two others that are similar can be confusing, but they are explained in the help as to when each is called and what its function is. I never remember so have to look it up each time I want to do something out of the ordinary with this.
4 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Graphics Objects 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!