Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

uisetcolor

Open color selection dialog box

Syntax

c = uisetcolor
c = uisetcolor([r g b])
c = uisetcolor(h)
c = uisetcolor(...,'dialogTitle')

Description

c = uisetcolor displays a modal color selection dialog box and returns the color selected by the user. The default color selection is [1 1 1] (white).

c = uisetcolor([r g b]) displays a dialog box with the specified default selection. r, g, and b must be values between 0 and 1.

c = uisetcolor(h) sets the default color to be to the value of the Color property of object h. After the user selects a color and clicks OK, uisetcolor applies the selected color to that object. h must be the an object containing the Color property.

c = uisetcolor(...,'dialogTitle') displays a dialog box with the specified title.

If the user presses Cancel from the dialog box, or if any error occurs, the output value is set to the input RGB triple, if provided; otherwise, it is set to 0.

Examples

Set Default Selection to Red

Open the color selection dialog box, and set the default selection to red.

c = uisetcolor([1 0 0])

Clicking OK without selecting a different color returns the default color.

c =

     1     0     0

Specify a Custom Title for the Dialog Box

Open the color selection dialog box, and set the title to be 'Select a Color'.

c = uisetcolor('Select a color')

Clicking OK without selecting a different color returns the default color, which is white.

c =

     1     1     1

More About

collapse all

Modal Dialog

A window that blocks interaction with other windows until the user closes the blocking window. For more information, see the figure WindowStyle property description.

Introduced before R2006a

Was this topic helpful?