MATLAB SIMULINK 7 - GRAPHICAL USER INTERFACE Podręcznik Użytkownika Strona 300

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 759
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 299
8 Programming a GUIDE GUI
button_state = get(hObject,'Value');
if button_st ate == get(hObject,'Max')
% Toggle button is pressed, take appropriate action
...
elseif butto n_st ate == get(hObject, 'Min ')
% Toggle button is not pressed, take appropri ate action
...
end
You can also change the state of a toggle button programmatically by setting
thetogglebutton
Value property to the value of its Max or Min property. This
example i llustrates a possible syntax for such an assignment.
set(handles.togglebutton1,'Value','Max' )
puts the toggle button with Ta g property togglebutton1 in the pressed state.
Note You can use a button group to m anage exclusive selection behavior for
toggle buttons. See “Button Group” on page 8-42 for more information.
Radio Button
You can determine the current state of a radio button from within its
Callback callback by querying the state of its Value property. If the radio
button is selected, its
Value property is equal to its Max property. If the radio
button is not selected, it is equal to its
Min property. This example illustrates
such a test.
function radiob utto n1_Callback(hObject, eventdata, handles)
if (get(hObj ect, 'Value') == get(hOb ject,'Max'))
% Radio button is selected, t ake appropriate action
else
% Radio button is not selecte d, take appropriate action
end
You can also change the state of a radio button programmatically by setting
the radio button
Value property to the value of the Max or Min property. This
example i llustrates a possible syntax for such an assignment.
set(handles.radiobutton1,'Value','Max')
8-32
Przeglądanie stron 299
1 2 ... 295 296 297 298 299 300 301 302 303 304 305 ... 758 759

Komentarze do niniejszej Instrukcji

Brak uwag