14 Examples of UIs Created Programmatically
mGetColorFcn = colorPalette('Parent',hPaletteContainer)
The colorPalette function accepts property name-value pairs as input arguments.
Only the Parent is supported. This property specifies the handle of the parent figure
or panel that contains the color palette. If the call to colorPalette does not specify a
parent, it uses the current figure, gcf. Unrecognized property names or invalid values
are ignored.
Copy and View the Color Palette Code
To obtain copies of the program files for this example, follow these steps:
1 Set your current folder to one for which you have write access.
2 Copy the example code to your folder. Then, open colorPalette.m in the Editor:
copyfile(fullfile(docroot, 'techdoc','creating_guis','examples',...
'colorPalette.m')), fileattrib('colorPalette.m', '+w');
copyfile(fullfile(docroot, 'techdoc','creating_guis','examples',...
'iconRead.m')), fileattrib('iconRead.m', '+w');
copyfile(fullfile(docroot, 'techdoc','creating_guis','examples',...
'eraser.gif')), fileattrib('eraser.gif', '+w');
edit colorPalette.m
CautionDo not modify and save the files to the examples folder from which you copied
them.
Local Function Summary for Color Palette
The color palette example includes the callbacks listed in the following table.
Function Description
colorCellCallback Called by hPalettePanelSelectionChanged when any
color cell is clicked.
eraserToolCallback Called by hPalettePanelSelectionChanged when the
Eraser button is clicked.
hMoreColorButtonCallback Executes when the More Colors button is clicked. It calls
uisetcolor to open the standard color-selection dialog box,
and calls localUpdateColor to update the preview.