How can I make warning message in GUI Matlab, when the user is closing the gui (using rght top 'x').
Asked
Active
Viewed 843 times
1
-
possible duplicate of [How can I program a GUI in MATLAB?](http://stackoverflow.com/questions/1115703/how-can-i-program-a-gui-in-matlab) – class stacker Jan 21 '14 at 16:02
-
1This is most definitely NOT a duplicate of referenced post. – chappjc Feb 28 '14 at 07:34
1 Answers
2
You can set the figure's CloseRequestFcn
to, for example, ask the user if they really want to close the figure or not. You can use a built-in modal window, like questdlg
, for this purpose. An example of such a function is given in the above documentation:
function my_closereq(src,evnt)
% User-defined close request function
% to display a question dialog box
selection = questdlg('Close This Figure?',...
'Close Request Function',...
'Yes','No','Yes');
switch selection,
case 'Yes',
delete(gcf)
case 'No'
return
end
end

gnovice
- 125,304
- 15
- 256
- 359