Specifications
4 Programming GUIs
4-18
Types of Callbacks
The primary mechanism for implementing a GUI is programming the callback
of the uicontrol objects used to build the interface. However, in addition to the
uicontrol
Callback property, there are other properties that enable you to
define callbacks.
Callback Properties for All Graphics Objects
All graphics objects have three properties that enable you to define callback
routines:
•
ButtonDownFcn – MATLAB executes this callback when users click the left
mouse button and the cursor is over the object or within a five-pixel border
around the object. See Which Callback Executes for information specific to
uicontrols
•
CreateFcn – MATLAB executes this callback when creating the object.
•
DeleteFcn – MATLAB executes this callback just before deleting the object.
Callback Properties for Figures
Figures have additional properties that execute callback routines with the
appropriate user action. Only the
CloseRequestFcn has a callback defined by
default:
•
CloseRequestFcn – MATLAB executes the specified callback when a request
is made to close the figure (by a
close command, by the window manager
menu, or by quitting MATLAB).
•
KeyPressFcn – MATLAB executes the specified callback when users press a
key and the cursor is within the figure window.
•
ResizeFcn – MATLAB executes the specified callback routine when users
resize the figure window.
•
WindowButtonDownFcn – MATLAB executes the specified callback when
users click the mouse button and the cursor is within the figure, but not over
an enabled uicontrol.
•
WindowButtonMotionFcn – MATLAB executes the specified callback when
users move the mouse button within the figure window.