
12 Examples of GUIs Created Programmatically
12-30
2 If it finds a match, processUserInputs assigns the value that was input for
the property to its variable in the third column of the
mPropertyDefs cell
array.
3 processUserInputs then calls the helper function specified in the second
column of the
mPropertyDefs cell array to validate the value that was
passed in for the property.
Passing Output to a Caller on Returning
If a host GUI calls the colorPalette function with an output argument, it
returns a function handle that the host GUI can call to get the currently
selected color.
The host GUI calls
colorPalette only once. The call creates the color palette
in the specified parent and then returns the function handle. The host GUI can
call the returned function at any time before the color palette is destroyed.
The data definition section of the
colorPalette M-file creates a cell array to
hold the output:
mOutputArgs = {}; % Variable for storing output when GUI returns
Just before returning, colorPalette assigns the function handle,
mgetSelectedColor, to the cell array mOutputArgs and then assigns
mOutputArgs to varargout to return the arguments.
mOutputArgs{} = @getSelectedColor;
if nargout>0
[varargout{1:nargout}] = mOutputArgs{:};
end
Sharing Data Between Two GUIs
The iconEditor embeds a GUI, the colorPalette, to enable the user to select
colors for the icon cells. The colorPalette returns a function handle the
iconEditor. The iconEditor can then call the returned function at any time to
get the selected color.
The colorPalette GUI. The colorPalette function defines a cell array,
mOutputArgs, to hold its output arguments.
mOutputArgs = {}; % Variable for storing output when GUI returns
Commentaires sur ces manuels