UI That Uses Persistent Data
guidata(hObject,handles)
end
end
Clear UI Fields
The Create New menu clears the Contact Name and Contact Phone # text fields to
facilitate adding a new name and number. The New_Callback callback sets the text
String properties to empty strings:
function New_Callback(hObject, eventdata, handles, varargin)
set(handles.Contact_Name,'String','')
set(handles.Contact_Phone,'String','')
Overall UI Characteristics
The UI window is nonblocking and nonmodal because it is designed to be displayed while
you perform other MATLAB tasks. There are various options, which you can view by
selecting Tools > GUI Options in GUIDE:
- Resize behavior: Other (Use SizeChangedFcn)
This sets the figure's SizeChangedFcn property to:
@(hObject,eventdata)address_book('Address_Book_SizeChangedFcn',...
hObject,eventdata,guidata(hObject))
- Command-line accessibility: Off
- Generate FIG file and MATLAB file (selected)
- Generate callback function prototypes (selected)
- GUI allows only one instance to run (singleton) (selected)
Window Resize Behavior
When you resize the UI, MATLAB calls the SizeChangedFcn callback. In this case, the
name of the SizeChangedFcn callback is Address_Book_SizeChangedFcn.
The SizeChangedFcn callback enables you to make the UI window wider, so it can
accommodate long names and numbers. However, you cannot make the UI window
narrower than its original width and you cannot change the height. These restrictions
simplify the callback, which must maintain the proper proportions between the figure
size and the components in the UI.