User`s guide

Ways to Manage Data in a GUIDE GUI
slider_data = getappdata(handles.figure1,'slider');
slider_data.number_errors = sli der_data.number_errors+1 ;
% Save the changes.
setappdata(handles.figure1,'slider', slider_data);
% Display new total.
set(hObject,'String',...
['You have entered an inval id entry ',...
num2str(slider_data.number_errors), ' times.']);
end
hObject
is the handle of the edit text component because this code appears in
the e dit text callback. The next-to-last line of the callback
uicontrol(hObject)
is useful, although not necessary for the callback to work properly. The call
to
uicontrol has the effect of placing the edit text box in focus. An edit text
control executes its callback after the user presses Return or clicks away
from the control. These actions both causetheedittextboxtolosefocus.
Restoring focus to it in the event of an error helps the user to understand
what action triggered the error. The user can then correct the error by typing
againintheedittextbox.
Sharing Data with GUI Data
To obtain copies of the GUI files for this example, follow the steps listed
below. If you are reading this in the MATLAB H elp browser, you can access
the example FIG-file and c ode file by clicking the followin g links. If you are
reading this on the Web or in PDF form, you should go to the corresponding
section in the MATLAB H elp Browser to use the links.
If you intend to modify the layout or code of this GUI example, you should
first save copies of its code file and F IG -file to your current folder. (You need
write a ccess to your current folder to do this.) Follow these steps to copy the
example files to your current folder, and then open them:
1 Click here to copy the files to your current folder.
2 guide sl ider box_guidata orclickheretoopentheGUIinGUIDE.
9-17