From Xojo Documentation


Color.SelectedFromDialog(ByRef col As Color, prompt As String [, showAlpha As Boolean = False]) As Boolean

New in 2019r2

Supported for all project types and targets.

Displays the system Color Picker, allowing the user to choose a color.


result = Color.SelectedFromDialog(ByRef col, prompt, showAlpha)

Part Type Description
result Boolean Returns True if the user clicks OK; False if the user cancels.
col Color Color passed to SelectColor and the color the user selects.

Note the usage of ByRef in the parameter list.

prompt String Prompt to be displayed in the Color Picker. Shown only on Linux.
showAlpha Boolean Shows alpha opacity in the Color Picker. Only for macOS. Defaults to False.


You control the default choice of color displayed by the Color Picker by passing a value of col to SelectColor. If col is not assigned a value, black is used as the default color. The color that the user chooses is returned in col. If the user clicks Cancel without making a choice, result is set to False; otherwise it is set to True.

Sample Code

The following example allows the user to select a color that will be used as the fillcolor in a Rectangle control.

Var c As Color
Var b As Boolean
c = Color.CMY(0.35, 0.9, 0.6, 0) // choose the default color shown in color picker
b = Color.SelectedFromDialog(c, "Select a Color")
Rectangle1.FillColor = c

If you don't want to test the boolean returned by SelectedFromDialog, you can call it using Call.

Call Color.SelectedFromDialog(c, "Select a Color")

See Also

Color data type; CMY, RGB, HSV functions; &c literal.