MATLAB SIMULINK 7 - GRAPHICAL USER INTERFACE Manuel d'utilisateur Page 174

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 330
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 173
8 Programming the GUI
8-2
Callbacks: An Overview
After you have laid out your GUI, you need to program its behavior. The code
you write controls how the GUI responds to events such as button clicks, slider
movement, menu item selection, or 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.
This chapter addresses the programming of GUIs created using GUIDE. In
particular, this section explains:
“What Is a Callback?” on page 8-2
“Kinds of Callbacks” on page 8-2
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 kind of
programming is often called event-driven programming.
When an event occurs for a component, MATLAB invokes the component’s
callback that is triggered by that event. As an example, suppose a GUI has a
button that triggers the plotting of some data. When the user clicks the button,
MATLAB calls the callback you associated with clicking that button, and the
callback, which you have programmed, then gets the data and plots it.
A component can be any control device such as a push button, list box, or slider.
It can also be a menu or a container such as a panel or button group. See
“Available Components” on page 6-14 for a list and descriptions of components.
Kinds of Callbacks
The GUI figure and each type of component has specific kinds of callbacks with
which it can be associated. The callbacks that are available for each component
are defined as properties of that component. For example, a push button has
five callback properties:
ButtonDownFcn, Callback, CreateFcn, DeleteFcn, and
KeyPressFcn. A panel has four callback properties: ButtonDownFcn, CreateFcn,
DeleteFcn, and ResizeFcn. You can, but are not required to, create a callback
function for each of these properties. The GUI itself, which is a figure, also has
certain kinds of callbacks with which it can be associated.
Vue de la page 173
1 2 ... 169 170 171 172 173 174 175 176 177 178 179 ... 329 330

Commentaires sur ces manuels

Pas de commentaire