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

  • 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 612
Examples: Program GUI C omponents
slider_value = get(hObject,'Value');
% Proceed with callback...
The Max an d Min properties specify the slider’s maximum and minimum
values. The slider’s range is
Max - Min. hObject is the handle of the
component for which the event was triggered.
Toggle Button
The callback for a toggle button needs to query the toggle button to determine
what state it is in. MATLAB software sets the
Value property equal to the
Max property when the toggle button is pressed (Max is 1 by default). It sets
the
Value property equal to the Min property when the toggle button is not
pressed (
Min is 0 by default).
The following code illustrates how to program the callback in the GUI code file.
function toggle butt on1_Callback(hObject,ev entdata)
button_state = get(hObject,'Value');
if button_st ate == get(hObject,'Max')
% Toggle button is pressed-tak e appropriate action
...
elseif butto n_st ate == get(hObject, 'Min ')
% Toggle button is not pressed-take appropria te action
...
end
hObject
is the handle of the component for which the event was triggered.
You can also change the state of a toggle button programmatically by setting
thetogglebutton
Value property to the value of the Max or Min property.
For example,
set(tbh,'Value','Max')
puts the toggle b utton with handle tbh in the pressed state.
12-27
Vue de la page 612
1 2 ... 608 609 610 611 612 613 614 615 616 617 618 ... 758 759

Commentaires sur ces manuels

Pas de commentaire