MATLAB Runtime Server | ![]() ![]() |
Using a Uicontrol or Uimenu to Exit the Application
In addition to adapting the CloseRequestFcn
, you might want to provide a button or menu option on the GUI that allows the user to exit the Runtime Server.
For example, a common GUI convention on most platforms is a File menu containing a Quit option. You can create a menu like this by using a uimenu object with 'shutdown'
as the callback, where shutdown.m
is a shut-down function that you write. For example,
fig = figure('HandleVisibility','Callback','Menubar','none',... 'CloseRequestFcn','shutdown'); filemmenu = uimenu(fig,'Label','&File'); quitmenu = uimenu(filemmenu,'Label','&Quit',... 'Accelerator','Q','Callback','shutdown');
Note
Although MATLAB figure windows are created with a default File menu that includes a Quit option, you may have disabled this menu by setting the figure's Menubar property to 'none' (see Preventing Command Window Input/Output).
|
You can create a Quit button in a similar way.
fig = figure('HandleVisibility','Callback','Menubar','none',... 'CloseRequestFcn','shutdown'); uicontrol(fig,'Style','Pushbutton','String','Quit',... 'Callback','shutdown')
![]() | Using the CloseRequestFcn to Exit the Application | Trapping Errors | ![]() |