User`s guide

10 Examples of GUIDE GUIs
)
set(handles.Contact_Phone,'String', Addresses(handles.Index) .Pho
ne)
return
end
The Contact Phone Number Callback
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, the callback opens a q uestion dialog box that asks you if
you w ant to change the existing number or cancel your change.
Like the Contact Name text box, this callback uses the index pointer
(
handles.Index) to update the new num ber in the address b ook and to revert
to the previously displayed number if the user clicks Cancel in the q uestion
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.
If you create a new entry, you must save the MAT-file with the File > Save
menu.
Contact_Phone_Callback Code Listing
function Contac t_Ph one_Callback(hObject, eventdata, handles)
Current_Phone = get(handles.Contact_Phone,'string');
% If either one is empty then return
if isempty(C urre nt_Phone)
return
end
% Get the current list of addresses from t he handles structure
Addresses = handles.Addresses;
Answer=questdlg('Do you want to change the pho ne number?', ...
'Change Phone Number', ...
'Yes','Cancel','Yes');
switch Answe r
case 'Yes'
% If no na me match was found create a new co ntact
Addresses(handles.Index).Phone = C urrent_Phone;
10-90