User`s guide
8 Programming a GUIDE GUI
Working with Callbacks in GUIDE
In this section...
“Programming GUIs Created Using GUIDE” on page 8-2
“What Is a Callback?” on page 8-2
“Kinds of Callbacks” on page 8-2
Programming GUIs Created Using GUIDE
After you have laid out your GUI, program its behavior. The code you write
controls how the GUI responds to events. Events include button clicks,
slider movements, menu item selections, and the creation and deletion of
components. This programming takes the form of a set of functions, called
callbacks, for each component and for the GUI figure itself.
What Is a Callback?
A callback is a function that you write and associate with a specific GUI
component or with the GUI figure. It controls GUI or component behavior
by performing some action in response to an event for its component. This
programming approach is often called event-driven pro gr a m m ing.
When an event occurs for a component, MA TLAB software invokes the
component’s callback that the event triggers. As an example, suppose a GUI
has a button that triggers the plotting of some data. When the GUI user
clicks the button, the software calls the callback you associated with clicking
that button. The callback, which you have programmed, then gets the data
and plots it.
A com ponent can be any control device such as a push button, list box, or
slider. For purposes of programming, it can also be a menu o r a container
such as a panel or button group. See “Available Components” on page 6-20 for
a list and descriptions of components.
KindsofCallbacks
The G UI figure and e ach type of component can trigger specific kinds of
callbacks. The callbacks that are available for each component are properties
8-2