how to change the Gui close function whithout changing the close function of figures ?
Afficher commentaires plus anciens
Hi, I'm trying to protect the close request function of my GUI with a yes/no question etc.
I've found some common way to do this in the matlab help :
set(0,'DefaultFigureCloseRequestFcn',@my_closereq).
This works but also changes the close function of the external figures and I don't want to.
I tried: set(hObject,'DefaultFigureCloseRequestFcn',@my_closereq)
But this gives the same problem.
Any Idea ?
Réponse acceptée
Plus de réponses (1)
Joseph Cheng
le 2 Juil 2014
I agree with Geoff Hayes and that should work. I did a quick example. I first created a function called closeRequest.m which contains the following.
function closeRequest(hObject,event)
ButtonName = questdlg('Close window?', ...
'Close Check', ...
'Yes', 'No','No');
switch ButtonName
case 'Yes'
delete(hObject);
case 'No'
return
end
then tested it with a simple script.
hObject = figure;
set(hObject,'CloseRequestFcn',@closeRequest)
plot(rand(10))
title('check close figure')
hObjects2 = figure;
plot(rand(100))
title('normally close figure')
by doing this only the first 'checked close' figure asks for the close dialog.
1 commentaire
Mathieu
le 2 Juil 2014
Catégories
En savoir plus sur Signal Operations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!