MATLAB SIMULINK 7 - GRAPHICAL USER INTERFACE Uživatelský manuál Strana 265

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 330
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 264
An Address Book Reader
10-41
Determining Which Button Is Clicked
The callback defines an additional argument, str, that indicates which button,
Prev or Next, was clicked. For the Prev button Callback property (illustrated
above), the
Callback string includes 'Prev' as the last argument. The Next
button
Callback string includes 'Next' as the last argument. The value of str
is used in
case statements to implement each button’s functionality (see the
code listing below).
Paging Forward or Backward
Prev_Next_Callback gets the current index pointer and the addresses from the
handles structure and, depending on which button the user presses, the index
pointer is decremented or incremented and the corresponding address and
phone number are displayed. The final step stores the new value for the index
pointer in the
handles structure and saves the updated structure using
guidata.
Code Listing
function Prev_Next_Callback(hObject, eventdata,handles,str)
% Get the index pointer and the addresses
index = handles.Index;
Addresses = handles.Addresses;
% Depending on whether Prev or Next was clicked,
% change the display
switch str
case 'Prev'
% Decrease the index by one
i = index - 1;
Zobrazit stránku 264
1 2 ... 260 261 262 263 264 265 266 267 268 269 270 ... 329 330

Komentáře k této Příručce

Žádné komentáře