MATLAB SIMULINK 7 - GRAPHICAL USER INTERFACE Manual do Utilizador Página 259

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 500
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 258
UI That Uses Persistent Data
9-13
switch Answer
case 'Yes'
Addresses(end+1).Name = Current_Name; % Grow array by 1
Addresses(end).Phone = Current_Phone;
index = length(Addresses);
handles.Addresses = Addresses;
handles.Index = index;
guidata(hObject,handles)
return
case 'Cancel'
% Revert back to the original number
set(handles.Contact_Name,'string',Addresses(handles.Index).Name)
set(handles.Contact_Phone,'String',Addresses(handles.Index).Phone)
return
end
Data Update Confirmation
The Contact Phone # text box displays the phone number of the entry listed in the
Contact Name text box. If you type in a new number and click one of the push buttons,
“Contact_Phone_Callback” on page 9-13 in address_book.m opens a question dialog
box that asks you if you want to change the existing number or cancel your change.
This callback uses the index pointer (handles.Index) to update the new number in the
address book and to revert to the previously displayed number if you click Cancel in the
question dialog box. Both the current address book and the index pointer are saved in the
handles structure so that this data is available to other callbacks.
Contact_Phone_Callback
function Contact_Phone_Callback(hObject, eventdata, handles, varargin)
Current_Phone = get(handles.Contact_Phone,'string');
% If either one is empty then return
if isempty(Current_Phone)
return
end
% Get the current list of addresses from the handles structure
Addresses = handles.Addresses;
Answer=questdlg('Do you want to change the phone number?', ...
'Change Phone Number', ...
'Yes','Cancel','Yes');
switch Answer
Vista de página 258
1 2 ... 254 255 256 257 258 259 260 261 262 263 264 ... 499 500

Comentários a estes Manuais

Sem comentários