Class

# DesktopColorPicker

<div class="rst-class">

forsearch

</div>

Color Picker

<div class="rst-class">

forsearch

</div>

ColorPicker

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Displays the operating system's color picker.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                      | Type                               | Read-Only | Shared |
|-------------------------------------------|------------------------------------|-----------|--------|
| `HasAlpha<desktopcolorpicker.hasalpha>`   | `Boolean</api/data_types/boolean>` |           |        |
| `IsVisible<desktopcolorpicker.Isvisible>` | `Boolean</api/data_types/boolean>` | ✓         |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                | Parameters                                                                                                                                                                                                                                                                                       | Returns                                     | Shared |
|-------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------|--------|
| `Close<desktopcolorpicker.close>`   |                                                                                                                                                                                                                                                                                                  |                                             |        |
| `Handle<desktopcolorpicker.handle>` |                                                                                                                                                                                                                                                                                                  | `Ptr</api/data_types/additional_types/ptr>` |        |
| `Show<desktopcolorpicker.show>`     | initialColor As `Color</api/data_types/color>`, prompt As `String</api/data_types/string>`, left As `Integer</api/data_types/integer>` = 0, top As `Integer</api/data_types/integer>` = 0, width As `Integer</api/data_types/integer>` = 230, height As `Integer</api/data_types/integer>` = 415 |                                             |        |

## Events

<div class="rst-class">

table-centered_column_4

</div>

| Name                                              | Parameters                                      | Returns |
|---------------------------------------------------|-------------------------------------------------|---------|
| `Closed<desktopcolorpicker.closed>`               |                                                 |         |
| `ColorSelected<desktopcolorpicker.colorselected>` | selectedColor As `Color</api/data_types/color>` |         |

## Property descriptions

<div id="desktopcolorpicker.hasalpha">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopColorPicker.HasAlpha

**HasAlpha** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the color selected will be returned with an alpha channel.
>
> The default value is `True</api/language/true>`.

<div id="desktopcolorpicker.Isvisible">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopColorPicker.IsVisible

**IsVisible** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the Color Picker is visible.
>
> The default value is `False</api/language/false>`.
>
> This property is read-only.

## Method descriptions

<div id="desktopcolorpicker.close">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopColorPicker.Close

**Close**

> Closes the <span class="title-ref">DesktopColorPicker</span> window.

<div id="desktopcolorpicker.handle">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopColorPicker.Handle

**Handle** As `Ptr</api/data_types/additional_types/ptr>`

> Returns a `Ptr</api/data_types/additional_types/ptr>` for use with `declares</api/language/declare>`.

<div id="desktopcolorpicker.show">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopColorPicker.Show

**Show**(initialColor As `Color</api/data_types/color>`, prompt As `String</api/data_types/string>`, left As `Integer</api/data_types/integer>` = 0, top As `Integer</api/data_types/integer>` = 0, width As `Integer</api/data_types/integer>` = 230, height As `Integer</api/data_types/integer>` = 415)

> Displays the operating system's color picker using the color, prompt, location and size passed.
>
> On macOS, once your app displays the Color Picker, the OS will continue to show it at that size regardless of what you pass as the width and height.
>
> The Prompt, Left, Top, Width and Height parameters are only supported on macOS.
>
> Additionally, on macOS should you have a <span class="title-ref">DesktopTextArea</span> on the layout in which you open the <span class="title-ref">DesktopColorPicker</span> and should that <span class="title-ref">DesktopTextArea</span> have the focus, the <span class="title-ref">DesktopColorPicker</span> will automatically set the color of the selection. This is simply how the <span class="title-ref">DesktopColorPicker</span> works on macOS. The workaround is to set first set the focus to the control that is calling the Show method:
>
> ``` xojo
> Self.SetFocus 
> ColorPicker1.Show(Color.Black, "Choose a color:") 
> ```

## Event descriptions

<div id="desktopcolorpicker.closed">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopColorPicker.Closed

**Closed**

> The color picker has been closed.

<div id="desktopcolorpicker.colorselected">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DesktopColorPicker.ColorSelected

**ColorSelected**(selectedColor As `Color</api/data_types/color>`)

> The user selected the color passed.

## Notes

On Windows and Linux, the operating system's color picker window is modal. On macOS, the color picker is not modal. This means that on macOS, the ColorSelected event will fire every time the user clicks on a color.

On macOS, if the Color Picker was left open when the user quit your app, it will be automatically closed upon relaunch.

## Sample code

The following code, in a `DesktopButton</api/user_interface/desktop/desktopbutton>` <span class="title-ref">Pressed</span> event, displays the <span class="title-ref">DesktopColorPicker</span> using the current background color of a `DesktopRectangle</api/user_interface/desktop/desktoprectangle>` as the initial color:

``` xojo
ColorPicker1.Show(Rectangle1.FillColor, "Choose a color:")
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

The following code, in the <span class="title-ref">DesktopColorPicker</span>'s `ColorSelected<desktopcolorpicker.colorselected>` event, updates the fill color of a `DesktopRectangle</api/user_interface/desktop/desktoprectangle>` with the *selectedColor* chosen by the user:

``` xojo
Rectangle1.FillColor = selectedColor
```

## Compatibility

|                       |         |
|-----------------------|---------|
| **Project Types**     | Desktop |
| **Operating Systems** | All     |

<div class="seealso">

`Object</api/data_types/additional_types/object>` parent class; `Color</api/data_types/color>` class.

</div>
