UI for a Program That Accepts Arguments
Function Description
hPalettePanelSelectionChangedExecutes when the user clicks on a new color. This is the
SectionChangeFcn callback of the uibuttongroup that
exclusively manages the tools and color cells that it contains.
It calls the appropriate callback to service each of the tools
and color cells.
The example also includes the helper functions listed in this table.
Function Description
layoutComponent Dynamically creates the Eraser tool and the color cells in
the palette. It calls localDefineLayout.
localUpdateColor Updates the preview of the selected color.
getSelectedColor Returns the currently selected color which is then
returned to the colorPalette caller.
localDefineLayout Calculates the preferred color cell and tool sizes
for the UI. It calls localDefineColors and
localDefineTools
localDefineTools Defines the tools shown in the palette. In this example,
the only tool is the Eraser button.
localDefineColors Defines the colors that are shown in the array of color
cells.
processUserInputs Determines if the property in a property-value pair is
supported. It calls localValidateInput.
localValidateInput Validates the value in a property-value pair.
Code File Organization
The color palette code uses nested functions. Its code file is organized in the following
sequence:
1 Comments displayed in response to the help command.
2 Data creation. Because the example uses nested functions, defining this data at the
top level makes the data accessible to all functions without having to pass them as
arguments.
3 Command line input processing.