Specifications
An Address Book Reader
5-43
end
end
The Create New Menu
The Create New menu simply clears the Contact Name and Contact Phone
#
text fields to facilitate adding a new name and number. After making the new
entries, the user must then save the address book with the
Save or Save As
menus. This callback sets the text
String properties to empty strings:
function New_Callback(hObject, eventdata, handles)
set(handles.Contact_Name,'String','')
set(handles.Contact_Phone,'String','')
The Address Book Resize Function
The address book defines its own resize function. To use this resize function,
you must set the
Application Options dialog Resize behavior to
User-specified, which in turn sets the figure’s ResizeFcn property to:
address_book('ResizeFcn',gcbo,[],guidata(gcbo))
Whenever the user resizes the figure, MATLAB calls the ResizeFcn
subfunction in the address book M-file (
address_book.m)
Behavior of the Resize Function
The resize function allows users to make the figure wider, to accommodate
long names and numbers, but does not allow the figure to be made narrower
than its original width. Also, users cannot change the height. These
restrictions do not limit the usefulness of the GUI and simplify the
resize
function, which must maintain the proper proportions between the figure size
and the components in the GUI.
When the user resizes the figure and releases the mouse, the resize function
executes. At that point, the resized figure’s dimensions are saved. The
following sections describe how the
resize function handles the various
possibilities.
Changing the Width
If the new width is greater than the original width, set the figure to the new
width.