User`s guide

15 Examples of GUIs Created Programmatically
mOutputArgs{} = mIco nCData;
if nargout>0
[varargout{1:nargout}] = mOutputAr gs{:};
end
This code is the last that iconEditor executes before returning. It
executes only after clicking the OK or Cancel button triggers execution of
hOKButtonCallback or hCancelButtonCallback, which call uiresume to
resume execution.
Protect a GUI from Inadvertent Access
The pre pare Layout utility function protects the iconEditor from inadvertently
being altered from the command line by setting the
HandleVisibility
properties of all the components. Code in the initialization section of
iconEditor calls
prepareLayout with the handle of the main figure.
% Make changes needed for prop er look and feel and running on
% different platforms
prepareLayout(hMainFigure);
prepareLayout
first uses findall to retrieve the handles of all objects
contained in the figure. The list of retrieved handles includes the
colorPalette, which is embedded in the iconEditor, and its children.
The figure’s handle is passed to
prepareLayout as the input argument
topContainer.
allObjects = findall(topContainer) ;
prepareLayout
then sets the HandleVisibility properties of all those
objects that have one to
Callback.
% Make GUI objects available t o callbacks so that they cannot
% be changed accidentally by other MATLAB comm ands
set(allObjects(isprop(allObjects,'H andleVisibility')),...
'HandleVisibility','Callback');
Setting HandleVisib ility to C allb ack causes the GUI handles to be visible
from within callback routines or functions invoked by callback routines, but
not from within functions invoked from the command line. This ensures
that command-line users cannot inadvertently alter the GUI w hen it is the
current figure.
15-74