
Color Palette
12-29
Passing Input Arguments to a GUI
Inputs to the GUI are custom property/value pairs. colorPalette allows one
such property:
Parent. The names are caseinsensitive. The colorPalette
syntax is
mGetColorFcn = colorPalette('Parent',hPaletteContainer)
Definition and Initialization of the Properties.
The colorPalette function first
defines a variable
mInputArgs as varargin to accept the user input arguments.
mInputArgs = varargin; % Command line arguments when invoking
% the GUI
The colorPalette function then defines the valid custom properties in a 3-by-3
cell array.
mPropertyDefs = {... % The supported custom property/value
% pairs of this GUI
'parent', @localValidateInput, 'mPaletteParent';
• The first column contains the property name.
• The second column contains a function handle for the function,
localValidateInput, that validates the input property values.
• 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
Processing 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.
% Process the command line input arguments supplied when
% the GUI is invoked
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.
Komentáře k této Příručce