| Products & Services | Industries | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
| On this page… |
|---|
A callback is a function that executes when a specific event occurs on a graphics object. You specify a callback by setting the appropriate property of the object. This section describes the events (specified via properties) for which you can define callbacks. See Function Handle Callbacks for information on how to define callbacks.
All graphics objects have three properties for which you can define callback routines:
ButtonDownFcn — Executes when you click the left mouse button while the cursor is over the object or within a 5-pixel border around the object.
CreateFcn — Executes during object creation after you set all properties.
DeleteFcn — Executes just before deleting the object.
User interface objects (e.g., uicontrol and uimenu) have a Callback property through which you define the function to execute when you activate these devices (e.g., click a push button or select a menu).
Figures have additional properties that execute callback routines with the appropriate user action. Only the CloseRequestFcn property has a callback defined by default:
CloseRequestFcn — Executes when a request is made to close the figure (by a close command, by the window manager menu, or by quitting MATLAB software).
KeyPressFcn — Executes when you press a key while the cursor is within the figure window.
ResizeFcn — Executes when you resize the figure window.
WindowButtonDownFcn — Executes when you click a mouse button while the cursor is over the figure background, a disabled uicontrol, or the axes background.
WindowButtonMotionFcn — Executes when you move the mouse button within the figure window (but not over menus or title bar).
WindowButtonUpFcn — Executes when you release the mouse button, after having pressed the mouse button within the figure.
![]() | Controlling Legends | Function Handle Callbacks | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |