Specifications

4 Programming GUIs
4-4
Callbacks — execute each time the user activates the corresponding
component of the GUI.
Common Input Arguments
All functions in the M-file have the following input arguments corresponding
to the handles structure:
hObject — the handle to the figure or Callback object
handles — structure with handles and user data (see guidata)
The
handles structure is saved at the end of each function with the command
guidata(hObject, handles);
Additional arguments for the opening and output functions are described in the
following sections.
Opening Function
The opening function contains code that is executed just before the GUI is
made visible to the user. You can access all the components for the GUI in the
opening function, because all objects in the GUI are created before the opening
function is called. You can add code to the opening function to perform tasks
that need to be done before the user has access to the GUI — for example,
creating data, plots or images, or making the GUI blocking with the
uiwait
command.
For a GUI whose file name is
my_gui, the definition line for the opening
function is
function my_gui_OpeningFcn(hObject, eventdata, handles, varargin)
Besides the arguments hObject and handles (see “Common Input Arguments”
preceding), the opening function has the following input arguments:
eventdata reserved for a future version of MATLAB
varargin command line arguments to untitled (see varargin)
All command line arguments are passed to the opening function via
varargin.
If you open the GUI with a property name/property value pair as arguments,
the GUI opens with the property set to the specified value. For example,