Specifications
The Generated M-File
2-15
The Generated M-File
Select Generate .fig file and .m file in the GUIDE Application Options dialog
if you want GUIDE to create both the FIG-file and the application M-file (this
is the default). Once you have selected this option, you can select any of the
following items in the frame to configure the M-file:
•Generate callback function prototypes
•Application allows only one instance to run
•Use system color scheme for background
•Function does not return until application window dismissed
Callback Function Names and Arguments
When you select Generate callback function prototypes in the GUIDE
Application Options dialog, GUIDE adds a subfunction to the application
M-file for any component you add to the GUI (note that frame and static text
components do not use their
Callback property and therefore have no
subfunction). You must then write the code for the callback in this subfunction.
GUIDE also adds a subfunction whenever you edit a callback routine from the
Layout Editor’s right-click context menu and when you add menus to the GUI
using the Menu Editor.
Naming Callback Subfunctions
When you add a component to your GUI layout, GUIDE assigns a value to its
Tag property, which is then used to generate the name of the callback.
For example, the first push button you add to the layout is tagged
pushbutton1.
When generating the application M-file, GUIDE adds a callback subfunction
called
pushbutton1_Callback. If you define a ButtonDownFcn for the same
push button, GUIDE names its subfunction
pushbutton1_ButtonDownFcn.
Callback Function Syntax
The callback function syntax is of the form
function varargout = objectTag_Callback(h,eventdata,handles,varargin)