User`s guide

Icon Editor
“Retrieve Output o n R eturn from a GUI” on page 15-73
“Protect a GUI from Inadvertent Access” on p age 15-74
“Run a GUI on Multiple Platforms” on page 15-75
“Make a GUI Modal” on page 15-76
“Share Data Between Two GUIs” on page 15-77
“Achieve Proper Resize Behavior” on page 15-78
Return Only After the User Makes a Choice
At the end of the initialization code, and just before returning, iconEditor calls
uiwait with the handle of the main figure to make the GUI blocking.
% Make the GUI blocking
uiwait(hMainFigure);
% Return the edited icon CD ata if it is requested
mOutputArgs{1} =hMainFigure;
mOutputArgs{2} =mIconCData;
if nargout>0
[varargout{1:nargout}] = mOutputAr gs{:};
end
Placement of the call to ui wait is important. C allin g ui wait stops the
sequential execution of
iconEdit.m after the GUI initializes and just before
the file would return the edited icon data.
When the user clicks the OK button, its callback,
hOKButtonCallback,calls
uiresume whichenablesthecodefiletoresumeexecutionwhereitstopped
and return the edited icon data.
function hOKBut tonC allback(hObject, ev entd ata)
% Callback called when the OK button is pr essed
uiresume;
delete(hMainFigure);
end
15-71