UI for a Program That Accepts Arguments
- The third column is the local variable that holds the value of the property.
colorPalette then initializes the properties with default values.
mPaletteParent = []; % Use input property 'parent' to initialize
Process the Input Arguments
The processUserInputs helper function processes the input property-value pairs.
colorPalette calls processUserInputs before it creates the components, to
determine the parent of the components.
processUserInputs();
1 processUserInputs sequences through the inputs, if any, and tries to match each
property name to a string in the first column of the mPropertyDefs cell array.
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.
Pass Output to a Caller on Returning
If a function calls the colorPalette function with an output argument, it returns a
function handle that you can call to get the currently selected color.
The function calls colorPalette only once. The call creates the color palette in the
specified parent and then returns the function handle.
The data definition section of the colorPalette code file creates a cell array to hold the
output:
mOutputArgs = {}; % Variable for storing output
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