MATLAB SIMULINK 7 - GRAPHICAL USER INTERFACE Guide de l'utilisateur Page 622

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 759
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 621
12 Code a Programmatic GUI
Open a Dialog Box from a Menu Callback
The Callback callback for the to file menu item could contain code such as
the following to display the standard dialog box for saving files.
[file,path] = uiputfile('animinit. m','Save file name' );
'Save file name'
is the d ialog box title. In the dialog box, the filename field
is set to
animinit.m, and the filter set to MATLAB language files (*.m). For
more information, see the
uiputfile reference page.
Note MATLAB software provides a selection of standard dialog boxes
that you can create with a single function call. For an example, see the
documentation for
msgbox, which also provides links to functions that create
specia lized predefine d di alog boxes.
Update a Menu Item Check
A check is useful to indicate the current state of some m enu items. If you set
the
Checked property to on wh en you create the menu item, the item initially
appears checked. Each time the user selects the menu item, the callback for
that item must turn the check on or off. The following example show s you how
to do this by changing the value of the menu item’s
Checked property.
function menu_c opyf ile(hObject,eventdata)
if strcmp(ge t(hO bject,'Checked'),'on')
set(hObject,'Checked','off');
else
set(hObject,'Checked','on');
end
hObject
is the handle of the component for which the event was triggered. Its
use here assumes the menu item’s
Callback property specifies the callback as
a function handle. See “Specify Callbacks in Function Calls” on page 12-11
for more information.
The
strcmp function compares two strings and returns logical 1 (true)ifthe
two are identical, and logical
0 (false) o the rwise.
12-36
Vue de la page 621
1 2 ... 617 618 619 620 621 622 623 624 625 626 627 ... 758 759

Commentaires sur ces manuels

Pas de commentaire