1

How can I make warning message in GUI Matlab, when the user is closing the gui (using rght top 'x').

tshepang
  • 12,111
  • 21
  • 91
  • 136

1 Answers1

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