Creating Graphical User Interfaces Previous page   Next Page

Types of Callbacks

The primary mechanism for implementing a GUI is programming the callbacks of the GUI components used to build the interface.

Callback Properties for All Graphics Objects

All graphics objects have three properties that enable you to define callback routines:

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:

Callbacks for Specific Components

Some components have additional properties that execute callback routines with the appropriate user action:

Which Callback Executes

Clicking on an enabled uicontrol prevents any ButtonDownFcn and WindowButtonDownFcn callbacks from executing. If you click on an inactive uicontrol, figure, or other graphics objects having callbacks defined, MATLAB first executes the WindownButtonDownFcn of the figure (if defined) and then the ButtonDownFcn of the object targeted by the mouse click.

Adding a Callback

To add a callback subfunction to the GUI M-file, click the right mouse button while the object is selected to display the Layout Editor context menu. Select the desired callback from the context menu and GUIDE adds the subfunction stub to the GUI M-file.


Previous page  Designing for Cross-Platform Compatibility Interrupting Executing Callbacks Next page

© 1994-2005 The MathWorks, Inc.