Class

# DesktopUIControl

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

## Description

<span class="title-ref">DesktopUIControl</span> is the base class for most other visual control classes.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                                        | Type                                                       | Read-Only | Shared |
|-------------------------------------------------------------|------------------------------------------------------------|-----------|--------|
| `Active<desktopuicontrol.active>`                           | `Boolean</api/data_types/boolean>`                         | ✓         |        |
| `AllowAutoDeactivate<desktopuicontrol.allowautodeactivate>` | `Boolean</api/data_types/boolean>`                         |           |        |
| `AllowTabStop<desktopuicontrol.allowtabstop>`               | `Boolean</api/data_types/boolean>`                         |           |        |
| `Enabled<desktopuicontrol.enabled>`                         | `Boolean</api/data_types/boolean>`                         |           |        |
| `Handle<desktopuicontrol.handle>`                           | `Ptr</api/data_types/additional_types/ptr>`                | ✓         |        |
| `Height<desktopuicontrol.height>`                           | `Integer</api/data_types/integer>`                         |           |        |
| `Index<desktopuicontrol.index>`                             | `Integer</api/data_types/integer>`                         |           |        |
| `Left<desktopuicontrol.left>`                               | `Integer</api/data_types/integer>`                         |           |        |
| `LockBottom<desktopuicontrol.lockbottom>`                   | `Boolean</api/data_types/boolean>`                         |           |        |
| `LockLeft<desktopuicontrol.lockleft>`                       | `Boolean</api/data_types/boolean>`                         |           |        |
| `LockRight<desktopuicontrol.lockright>`                     | `Boolean</api/data_types/boolean>`                         |           |        |
| `LockTop<desktopuicontrol.locktop>`                         | `Boolean</api/data_types/boolean>`                         |           |        |
| `MouseCursor<desktopuicontrol.mousecursor>`                 | `MouseCursor</api/user_interface/desktop/mousecursor>`     |           |        |
| `Name<desktopuicontrol.name>`                               | `String</api/data_types/string>`                           | ✓         |        |
| `PanelIndex<desktopuicontrol.panelindex>`                   | `Integer</api/data_types/integer>`                         |           |        |
| `Parent<desktopuicontrol.parent>`                           | `Object</api/data_types/additional_types/object>`          |           |        |
| `Scope<desktopuicontrol.scope>`                             | `Integer</api/data_types/integer>`                         | ✓         |        |
| `TabIndex<desktopuicontrol.tabindex>`                       | `Integer</api/data_types/integer>`                         |           |        |
| `Tooltip<desktopuicontrol.tooltip>`                         | `String</api/data_types/string>`                           |           |        |
| `Top<desktopuicontrol.top>`                                 | `Integer</api/data_types/integer>`                         |           |        |
| `Transparent<desktopuicontrol.transparent>`                 | `Boolean</api/data_types/boolean>`                         |           |        |
| `Visible<desktopuicontrol.visible>`                         | `Boolean</api/data_types/boolean>`                         |           |        |
| `Width<desktopuicontrol.width>`                             | `Integer</api/data_types/integer>`                         |           |        |
| `Window<desktopuicontrol.window>`                           | `DesktopWindow</api/user_interface/desktop/desktopwindow>` | ✓         |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                                    | Parameters                                                                                                                                                                                                                                                    | Returns | Shared |
|---------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|--------|
| `AcceptFileDrop<desktopuicontrol.acceptfiledrop>`       | FileType As `String</api/data_types/string>`                                                                                                                                                                                                                  |         |        |
| `AcceptPictureDrop<desktopuicontrol.acceptpicturedrop>` |                                                                                                                                                                                                                                                               |         |        |
| `AcceptRawDataDrop<desktopuicontrol.acceptrawdatadrop>` | Type As `String</api/data_types/string>`                                                                                                                                                                                                                      |         |        |
| `AcceptTextDrop<desktopuicontrol.accepttextdrop>`       |                                                                                                                                                                                                                                                               |         |        |
| `Close<desktopuicontrol.close>`                         |                                                                                                                                                                                                                                                               |         |        |
| `DrawInto<desktopuicontrol.drawinto>`                   | g As `Graphics</api/graphics/graphics>`, x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`                                                                                                                                     |         |        |
| `Refresh<desktopuicontrol.refresh>`                     | immediately As `Boolean</api/data_types/boolean>` = `False</api/language/false>`                                                                                                                                                                              |         |        |
|                                                         | x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`, width As `Integer</api/data_types/integer>`, height As `Integer</api/data_types/integer>`, immediately As `Boolean</api/data_types/boolean>` = `False</api/language/false>` |         |        |
| `SetFocus<desktopuicontrol.setfocus>`                   |                                                                                                                                                                                                                                                               |         |        |

## Events

<div class="rst-class">

table-centered_column_4

</div>

| Name                                                                      | Parameters                                                                                                                                                                            | Returns                            |
|---------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------|
| `Closing<desktopuicontrol.closing>`                                       |                                                                                                                                                                                       |                                    |
| `ConstructContextualMenu<desktopuicontrol.constructcontextualmenu>`       | Base As `DesktopMenuItem</api/user_interface/desktop/desktopmenuitem>`, x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`                              | `Boolean</api/data_types/boolean>` |
| `ContextualMenuItemSelected<desktopuicontrol.contextualmenuitemselected>` | HitItem As `DesktopMenuItem</api/user_interface/desktop/desktopmenuitem>`                                                                                                             | `Boolean</api/data_types/boolean>` |
| `DragEnter<desktopuicontrol.dragenter>`                                   | obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `DragItem.Types<dragitem.types>`                                                                                   | `Boolean</api/data_types/boolean>` |
| `DragExit<desktopuicontrol.dragexit>`                                     | obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `DragItem.Types<dragitem.types>`                                                                                   |                                    |
| `DragOver<desktopuicontrol.dragover>`                                     | x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`, obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `DragItem.Types<dragitem.types>` | `Boolean</api/data_types/boolean>` |
| `DrawControlInLayoutEditor<desktopuicontrol.drawcontrolinlayouteditor>`   | g As `Graphics</api/graphics/graphics>`                                                                                                                                               |                                    |
| `DropObject<desktopuicontrol.dropobject>`                                 | Obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `DragItem.Types<dragitem.types>`                                                                                   |                                    |
| `FocusLost<desktopuicontrol.focuslost>`                                   |                                                                                                                                                                                       |                                    |
| `FocusReceived<desktopuicontrol.focusreceived>`                           |                                                                                                                                                                                       |                                    |
| `KeyDown<desktopuicontrol.keydown>`                                       | Key As `String</api/data_types/string>`                                                                                                                                               | `Boolean</api/data_types/boolean>` |
| `KeyUp<desktopuicontrol.keyup>`                                           | Key As `String</api/data_types/string>`                                                                                                                                               |                                    |
| `MouseDown<desktopuicontrol.mousedown>`                                   | X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`                                                                                                      | `Boolean</api/data_types/boolean>` |
| `MouseDrag<desktopuicontrol.mousedrag>`                                   | X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`                                                                                                      |                                    |
| `MouseEnter<desktopuicontrol.mouseenter>`                                 |                                                                                                                                                                                       |                                    |
| `MouseExit<desktopuicontrol.mouseexit>`                                   |                                                                                                                                                                                       |                                    |
| `MouseMove<desktopuicontrol.mousemove>`                                   | X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`                                                                                                      |                                    |
| `MouseUp<desktopuicontrol.mouseup>`                                       | X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`                                                                                                      |                                    |
| `MouseWheel<desktopuicontrol.mousewheel>`                                 | X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`, DeltaX As `Integer</api/data_types/integer>`, DeltaY As `Integer</api/data_types/integer>`          | `Boolean</api/data_types/boolean>` |
| `Opening<desktopuicontrol.opening>`                                       |                                                                                                                                                                                       |                                    |

## Constants

> These constants are designed to be used with the <span class="title-ref">DesktopUIControl</span> to show icons at the Navigator and Library.
>
> For a *LibraryIcon* aim for 48x48, but note that these will scale depending on the Library settings. Currently we don't provide a way to specify all the acceptable sizes, i.e. 16x16, 32x32, 48x48. For a *NavigatorIcon* 16x16 is sufficient.
>
> | Name          | Description                                                                                                                                                             |
> |---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
> | NavigatorIcon | This constant is used to override the icon of your control in the Navigator. Using the WebSDKIconConverter, place the Base64 icon data into the value of this constant. |
> | LibraryIcon   | This constant is used to override the icon of your control in the Library. Using the WebSDKIconConverter, place the Base64 icon data into the value of this constant.   |
>
> The following class constants of the `DragItem</api/user_interface/desktop/dragitem>` class can be used to specify the value of the *Action* parameter with the `DragEnter<desktopuicontrol.dragenter>`, `DragExit<desktopuicontrol.dragexit>`, and `DragOver<desktopuicontrol.dragover>` events.
>
> | Class Constant    | Description            |
> |-------------------|------------------------|
> | DragActionDefault | Default action.        |
> | DragActionCopy    | Copy the dragged item. |
> | DragActionMove    | Move the dragged item. |
> | DragActionLink    | Link the dragged item. |

## Property descriptions

<div id="desktopuicontrol.active">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.Active

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

> Indicates whether the <span class="title-ref">DesktopUIControl</span> is active.
>
> Active is `False</api/language/false>` when the control's window is not in the foreground. When a `DesktopWindow</api/user_interface/desktop/desktopwindow>` is deactivated, its controls are automatically deactivated unless `AllowAutoDeactivate<desktopuicontrol.allowautodeactivate>` is set to `False</api/language/false>`.
>
> This property is read-only.

<div id="desktopuicontrol.allowautodeactivate">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.AllowAutoDeactivate

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

> Determines whether the control should be deactivated (on macOS) when the parent window is deactivated. The default is `True</api/language/true>`.

<div id="desktopuicontrol.allowtabstop">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.AllowTabStop

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

> If `True</api/language/true>`, the control is in the Tab Order and accepts the focus when the user tabs into it. The default is `True</api/language/true>`. If `False</api/language/false>`, the user cannot tab into it to give it the focus. However, the control can gain the focus by other means, such as the user's clicking on it or by setting the focus in code.
>
> This example removes the control from the Tab Order:
>
> ``` xojo
> Me.AllowTabStop = False
> ```

<div id="desktopuicontrol.enabled">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.Enabled

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

> Determines if the control should be enabled when the owning window is opened.
>
> A disabled control cannot be clicked and cannot receive the focus.
>
> This example disables the control.
>
> ``` xojo
> Me.Enabled = False
> ```

<div id="desktopuicontrol.handle">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.Handle

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

> Returns a handle to the control.
>
> This property is read-only.
>
> For interfacing with Mac APIs using `Declares</api/language/declare>`, **DesktopControl.Handle** returns NSViews (except for `DesktopToolbar</api/user_interface/desktop/desktoptoolbar>`).
>
> On Windows returns the HWND of the control.
>
> On Linux it returns a GtkWidget.
>
> The following gets a handle to the control.
>
> ``` xojo
> Var p As Ptr = Me.Handle
> ```

<div id="desktopuicontrol.height">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.Height

**Height** As `Integer</api/data_types/integer>`

> The height (in points) of the control.
>
> This example sets the height of the control to 100:
>
> ``` xojo
> Me.Height = 100
> ```

<div id="desktopuicontrol.index">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.Index

**Index** As `Integer</api/data_types/integer>`

> If the control is used in a control set, this specifies the control's index in the set.

<div id="desktopuicontrol.left">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.Left

**Left** As `Integer</api/data_types/integer>`

> The distance from the left side of the control to the left side of its containing window or container.
>
> The following example moves the control 100 points from the left side of the window:
>
> ``` xojo
> Me.Left = 150
> ```

<div id="desktopuicontrol.lockbottom">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.LockBottom

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

> Determines whether the bottom edge of the control should stay at a set distance from the bottom edge of the parent control, if there is one, or the owning window.
>
> This property can be set in the control's Inspector. The following example sets it in code.
>
> ``` xojo
> Me.LockBottom = True
> ```

<div id="desktopuicontrol.lockleft">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.LockLeft

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

> Determines whether the left edge of the control should stay at a set distance from the left edge of the parent control, if there is one, or the owning window.
>
> LockLeft and Locktop default to `True</api/language/true>` when you add a new control to a window. Existing controls will be altered only if LockRight and/or LockBottom are not set. *LockLeft* has no effect unless *LockRight* is `True</api/language/true>`.
>
> This property can be set in the control's Inspector. The following example sets it in code.
>
> ``` xojo
> Me.LockLeft = True
> ```

<div id="desktopuicontrol.lockright">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.LockRight

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

> Determines whether the right edge of the control should stay at a set distance from the right edge of the parent control, if there is one, or the owning window.
>
> This property can be set in the control's Inspector. The following example sets it in code.
>
> ``` xojo
> Me.LockRight = True
> ```

<div id="desktopuicontrol.locktop">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.LockTop

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

> Determines whether the top edge of the control should stay at a set distance from the top edge of the parent control, if there is one, or the owning window.
>
> LockTop and LockLeft default to `True</api/language/true>` when you add a control to a window. Existing controls will be altered only if LockRight and/or LockBottom are not set. *LockTop* has no effect unless *LockBottom* is `True</api/language/true>`.
>
> This property can be set in the control's Inspector. The following example sets it in code.
>
> ``` xojo
> Me.LockTop = True
> ```

<div id="desktopuicontrol.mousecursor">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.MouseCursor

**MouseCursor** As `MouseCursor</api/user_interface/desktop/mousecursor>`

> The cursor to be displayed while the mouse is within the control and both the `DesktopApplication</api/user_interface/desktop/desktopapplication>` and `DesktopWindow</api/user_interface/desktop/desktopwindow>` class's MouseCursor properties are `Nil</api/language/nil>`.
>
> If the `DesktopApplication</api/user_interface/desktop/desktopapplication>` class's MouseCursor property is not `Nil</api/language/nil>` or the `DesktopWindow</api/user_interface/desktop/desktopwindow>`'s MouseCursor property is not `Nil</api/language/nil>`, then any control's MouseCursor property is ignored. You can use a cursor stored in the `Cursors</api/user_interface/desktop/cursors>` module. On Macintosh, you can also obtain a `MouseCursor</api/user_interface/desktop/mousecursor>` from a resource file.
>
> This line in the Opening event of the control sets the default cursor to the finger pointer.
>
> ``` xojo
> Me.MouseCursor = System.Cursors.FingerPointer
> ```

<div id="desktopuicontrol.name">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.Name

**Name** As `String</api/data_types/string>`

> The name of the control. Set the name of the control in the Inspector.
>
> This property is read-only.

<div id="desktopuicontrol.panelindex">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.PanelIndex

**PanelIndex** As `Integer</api/data_types/integer>`

> If the control has been placed on a `DesktopTabPanel</api/user_interface/desktop/desktoptabpanel>` or `DesktopPagePanel</api/user_interface/desktop/desktoppagepanel>` control, this is the panel (page/tab) that the control is on. If the control is not on a panel, it returns -1.
>
> The first panel is numbered zero. If the control has been placed on a panel of a `DesktopTabPanel</api/user_interface/desktop/desktoptabpanel>` or `DesktopPagePanel</api/user_interface/desktop/desktoppagepanel>` control, it returns the panel number. If the control is not on a `DesktopPagePanel</api/user_interface/desktop/desktoppagepanel>` or `DesktopTabPanel</api/user_interface/desktop/desktoptabpanel>`, it returns -1. If you change the PanelIndex to a nonexistent panel, the control will disappear until you give it a PanelIndex value that corresponds to a panel that exists.
>
> If you are looking to change the currently selected panel (page/tab), use `DesktopPagePanel<desktoppagepanel.selectedpanelindex>`.
>
> This code displays the panel index of the control that is on the page.
>
> ``` xojo
> MessageBox(Me.SelectedPanelIndex.ToString)
> ```

<div id="desktopuicontrol.parent">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.Parent

**Parent** As `Object</api/data_types/additional_types/object>`

> Used to get and set the control's parent control or window.
>
> If the control is on the window, the Parent will be the `Window</api/user_interface/desktop/desktopwindow>`. If the control is on the container, the Parent will be the `container</api/user_interface/desktop/desktopcontainer>`. If the control is completed enclosed by another control, the Parent will be that <span class="title-ref">DesktopUIControl</span>.
>
> If you do not want the enclosing control to be the parent, set the Parent property of that control to `Nil</api/language/nil>` to make it the `Window</api/user_interface/desktop/desktopwindow>`.
>
> If the parent control is somehow in another window, an `InvalidParentException</api/exceptions/invalidparentexception>` will occur.
>
> The following example sets the parent of the control to the window.
>
> ``` xojo
> Me.Parent = Nil
> ```

<div id="desktopuicontrol.scope">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.Scope

**Scope** As `Integer</api/data_types/integer>`

> Used to determine whether access to the control is Public (0) or Private (2). The default is Public.
>
> This property is read-only.
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> This is a designtime-only property and thus can only be set in the Inspector and is not accessible via code.
>
> </div>
>
> If the Scope of a control is set to Private, it cannot be accessed from outside its parent window.

<div id="desktopuicontrol.tabindex">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.TabIndex

**TabIndex** As `Integer</api/data_types/integer>`

> The control's position in the Tab Order. The control with whose TabIndex is 0 will get the focus first.
>
> On macOS, only controls where you enter data from the keyboard typically get the focus. In order to manually set focus to controls that don't allow keyboard entry, go to System Preferences, click on the Keyboard icon then on the Shortcuts tab and then check the *Use keyboard navigation to move focus between controls* checkbox.
>
> This example sets the control's TabIndex.
>
> ``` xojo
> Me.TabIndex = 2
> ```

<div id="desktopuicontrol.tooltip">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.Tooltip

**Tooltip** As `String</api/data_types/string>`

> Text of help message displayed as a Windows or Linux "tooltip" or macOS help tag.
>
> The tip/tag is displayed when the user hovers the mouse cursor over the control.
>
> This example adds a tooltip to a control:
>
> ``` xojo
> Me.Tooltip = "Click to bark."
> ```

<div id="desktopuicontrol.top">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.Top

**Top** As `Integer</api/data_types/integer>`

> The distance from the top of the control to the top of its containing window or container.
>
> This example sets the top of the control to 140 points from the top of the window:
>
> ``` xojo
> Me.Top = 140
> ```

<div id="desktopuicontrol.transparent">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.Transparent

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

> Determines whether the control is transparent on Windows. The default is `False</api/language/false>`. Has no effect on macOS or Linux.
>
> Transparent controls draw more slowly and use more memory in order to cache the background. Unless you absolutely require transparency, leave this set to `False</api/language/false>`.
>
> For projects that were created prior to 2018r1, this property defaults to `True</api/language/true>` to emulate previous behavior. Consider changing it to `False</api/language/false>` to improve performance if you do not require transparency.

<div id="desktopuicontrol.visible">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.Visible

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

> Determines whether the control is visible when its owning window is opened. The default is `True</api/language/true>`: the control is visible.
>
> The following code makes the control invisible:
>
> ``` xojo
> Me.Visible = False
> ```

<div id="desktopuicontrol.width">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.Width

**Width** As `Integer</api/data_types/integer>`

> The width (in points) of the control.
>
> The following example resizes the control:
>
> ``` xojo
> Me.Width = 200
> ```

<div id="desktopuicontrol.window">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.Window

**Window** As `DesktopWindow</api/user_interface/desktop/desktopwindow>`

> The control's parent window.
>
> This property is read-only.
>
> This code gets the parent window's Title property.
>
> ``` xojo
> MessageBox(Me.Window.Title)
> ```

## Method descriptions

<div id="desktopuicontrol.acceptfiledrop">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.AcceptFileDrop

**AcceptFileDrop**(FileType As `String</api/data_types/string>`)

> Permits documents of type *FileType* to be dropped on the control. *FileType* must be a file type that you defined in via the `FileType</api/files/filetype>` class or the File Type Sets Editor.
>
> This code in the Opening event makes it possible for the user to drop either a picture or a file that is a jpeg image. The File Type Sets editor was used to define the “image/jpeg” file type. It is one of the “Common File Types” that is available in the editor.
>
> ``` xojo
> Me.AcceptPictureDrop
> Me.AcceptFileDrop("image/jpeg")
> ```
>
> To restrict file drops to specific file types on macOS, in addition to creating a File Type (as a `project item</getting_started/using_the_ide/file_type_group_editor>` or `via code</api/files/filetype>`) to define the file extension, you must also use the `DragEnter<desktopuicontrol.dragenter>` event:
>
> For example, to restrict drops to folders only:
>
> ``` xojo
> If Not obj.FolderItem.IsFolder Then Return True
> ```
>
> To restrict drops to a files with a specific extension:
>
> ``` xojo
> If Not obj.FolderItem.Extension <> ".my_extension" Then Return True
> ```

<div id="desktopuicontrol.acceptpicturedrop">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.AcceptPictureDrop

**AcceptPictureDrop**

> Permits pictures to be dropped on the control.
>
> If a control should accept pictures in a drag and drop, then AcceptPictureDrop needs to be called prior to the drop. Typically, it is in the Opening event of the control itself. For example, the line:
>
> ``` xojo
> Me.AcceptPictureDrop
> ```
>
> in the Opening event of the control that will receive the dragged pictures is needed. When the picture is dropped, the `DropObject<desktopuicontrol.dropobject>` event is called and this is where you will put your code to handle the drop.
>
> Opening Event:
>
> ``` xojo
> Me.AcceptPictureDrop
> ```
>
> DropObject Event:
>
> ``` xojo
> If obj.PictureAvailable Then
>   Me.Backdrop = obj.Picture
> End If
> ```

<div id="desktopuicontrol.acceptrawdatadrop">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.AcceptRawDataDrop

**AcceptRawDataDrop**(Type As `String</api/data_types/string>`)

> Permits data (of the Type specified) to be dropped on the control.
>
> The following specfies a generic file type defined in the File Type Sets editor.
>
> ``` xojo
> Me.AcceptRawDataDrop("????")
> ```

<div id="desktopuicontrol.accepttextdrop">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.AcceptTextDrop

**AcceptTextDrop**

> Permits text to be dropped on the control.
>
> This line in the Opening event of a control that can accept dragged text.
>
> ``` xojo
> Me.AcceptTextDrop
> ```

<div id="desktopuicontrol.close">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.Close

**Close**

> Closes a control.
>
> Closing a control permanently removes the control from memory, making it impossible to access. You can close both non-indexed controls and indexed controls. When you close an indexed control, the indexes for the remaining controls will shift downward so that the indexes start with zero and are consecutive.
>
> The following code closes the control. When this is executed from a visible control, the control disappears from the window.
>
> ``` xojo
> Me.Close
> ```

<div id="desktopuicontrol.drawinto">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.DrawInto

**DrawInto**(g As `Graphics</api/graphics/graphics>`, x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`)

> Draws the contents of the control into the specified `Graphics</api/graphics/graphics>` context. The parameters *x* and *y* are the coordinates of the top, left corner.
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> DrawInto will only work if the control is on a window or container.
>
> </div>
>
> This example draws the current control into the Graphics of a Picture and then displays it as the Backdrop of a Canvas:
>
> ``` xojo
> Var p As New Picture(Me.Width, Me.Height)
> Me.DrawInto(p.Graphics, 0, 0)
> Canvas1.Backdrop = p
> ```

<div id="desktopuicontrol.refresh">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.Refresh

**Refresh**(immediately As `Boolean</api/data_types/boolean>` = `False</api/language/false>`)

> Redraws the portion specified of the contents of the control the next time the OS redraws the control or immediately if `True</api/language/true>` is passed.
>
> If you are calling this so frequently that you experience a slowdown in your code, pass `True</api/language/true>` for the immediately parameter.
>
> Calling this method causes the Render event to fire.
>
> Refresh the entire area immediately:
>
> ``` xojo
> Me.Refresh(True)
> ```
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> If you are updating the window in a tight loop, consider instead using `App.DoEvents<desktopapplication.doevents>`.
>
> </div>

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

<div class="rst-class">

forsearch

</div>

DesktopUIControl.Refresh

**Refresh**(x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`, width As `Integer</api/data_types/integer>`, height As `Integer</api/data_types/integer>`, immediately As `Boolean</api/data_types/boolean>` = `False</api/language/false>`)

> Redraws the portion specified of the contents of the control the next time the OS redraws the control or immediately if `True</api/language/true>` is passed.
>
> Refresh a portion of the area the next time the OS redraws the control:
>
> ``` xojo
> Me.Refresh(100, 150, 200, 300)
> ```

<div id="desktopuicontrol.setfocus">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.SetFocus

**SetFocus**

> If applicable and the control is enabled, sets the focus to the <span class="title-ref">DesktopUIControl</span>. KeyDown events are directed to the control.
>
> If the control cannot get the focus on the platform on which the application is running, SetFocus does nothing. The SetFocus method of the `DesktopWindow</api/user_interface/desktop/desktopwindow>` class or the `ClearFocus</api/user_interface/desktop/clearfocus>` method can be used to remove the focus from the control that currently has the focus, leaving no control with the focus.
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> On macOS, you need Full Keyboard Access turned on in System Preferences (Keyboard-\>Shortcuts) in order to manually set focus to non-text controls.
>
> </div>
>
> The following example in the Opening event sets the focus to the that control. If another control has the focus when this line is executed, then the user sees this control gets the focus.
>
> ``` xojo
> Me.SetFocus
> ```

## Event descriptions

<div id="desktopuicontrol.closing">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.Closing

**Closing**

> The control is closing.

<div id="desktopuicontrol.constructcontextualmenu">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.ConstructContextualMenu

**ConstructContextualMenu**(Base As `DesktopMenuItem</api/user_interface/desktop/desktopmenuitem>`, x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`) As `Boolean</api/data_types/boolean>`

> This event is called when it is appropriate to display a contextual menu for the control.
>
> This event handler is the recommended way to handle contextual menus because this event figures out whether the user has requested the contextual menu, regardless of how they did it. Depending on platform, it might be in the `MouseUp<desktopuicontrol.mouseup>` or `MouseDown<desktopuicontrol.mousedown>` event and it might be a right+click or by pressing the contextual menu key on the keyboard, for example.
>
> *Base* is analogous to the menu bar for the contextual menu. Any items you add to *Base* will be shown as menu items. If you return `False</api/language/false>`, the event is passed up the parent hierarchy.
>
> If you return `True</api/language/true>`, the contextual menu is displayed. The parameters *x* and *y* are the mouse locations. If the event was fired because of a non-mouse event, then *x* and *y* are both set to -1. See the example of a contextual menu in the following section.
>
> The following ConstructContextualMenu event handler builds a menu with three menu items plus a submenu with three additional menu items.
>
> ``` xojo
> ' Add some items
> base.AddMenu(New DesktopMenuItem("Test 1"))
> base.AddMenu(New DesktopMenuItem("Test 2"))
> base.AddMenu(New DesktopMenuItem("Test 3"))
>
> ' Add a Separator
> base.AddMenu(New DesktopMenuItem(DesktopMenuItem.TextSeparator))
>
> ' Add a sub menu
> Var submenu As New DesktopMenuItem("SubMenu")
> submenu.AddMenu(New DesktopMenuItem("SubMenu Test 1"))
> submenu.AddMenu(New DesktopMenuItem("SubMenu Test 2"))
> submenu.AddMenu(New DesktopMenuItem("SubMenu Test 3"))
> base.AddMenu(submenu)
>
> ' Add a Separator
> base.AddMenu(New DesktopMenuItem(DesktopMenuItem.TextSeparator))
>
> Return True
> ```

<div id="desktopuicontrol.contextualmenuitemselected">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.ContextualMenuItemSelected

**ContextualMenuItemSelected**(HitItem As `DesktopMenuItem</api/user_interface/desktop/desktopmenuitem>`) As `Boolean</api/data_types/boolean>`

> Fires when a contextual menuitem *selectedItem* was selected but the `MenuItemSelected<desktopmenuitem.menuitemselected>` event and the MenuHandler for the `DesktopMenuItem</api/user_interface/desktop/desktopmenuitem>` did not handle the menu selection.
>
> This event gives you a chance to handle the menu selection by inspecting the menuitem's Text or Tag properties to see which item was selected. Use this in conjunction with ConstructContextualMenu if you have not specified the `MenuItemSelected<desktopmenuitem.menuitemselected>` event or the Menu Handler for the items on the contextual menu. See the example of a contextual menu in the examples for the <span class="title-ref">DesktopUIControl</span> class.
>
> `Return</api/language/return>` `True</api/language/true>` if this event has handled the item the user chose from the contextual menu. Returning `False</api/language/false>` will cause the control's parent to execute its ContextualMenuItemSelected event. This can be handy if you have the same contextual menu for several controls who share the same `Parent<desktopuicontrol.parent>` (several on the same window for example). By returning `False</api/language/false>` you can handle them all in a single event.
>
> This simple event handler displays the value of the selected menu item.
>
> ``` xojo
> If selectedItem <> Nil Then MessageBox(selectedItem.Text)
> Return True
> ```

<div id="desktopuicontrol.dragenter">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.DragEnter

**DragEnter**(obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `DragItem.Types<dragitem.types>`) As `Boolean</api/data_types/boolean>`

> Fires when the passed `DragItem</api/user_interface/desktop/dragitem>` enters the <span class="title-ref">DesktopUIControl</span>.
>
> Returns a `Boolean</api/data_types/boolean>`. Return `True</api/language/true>` from this event to prevent the drop from occurring.
>
> The Action parameter specifies the type of drag action.
>
> To restrict file drops to just folders (and not files), you can put this code in the DragEnter event:
>
> ``` xojo
> If Not obj.FolderItem.IsFolder Then Return True
> ```

<div id="desktopuicontrol.dragexit">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.DragExit

**DragExit**(obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `DragItem.Types<dragitem.types>`)

> Fires when the passed `DragItem</api/user_interface/desktop/dragitem>` exits the <span class="title-ref">DesktopUIControl</span>.
>
> The *Obj* parameter is the item being dragged. The *Action* parameter specifies the type of drag action.

<div id="desktopuicontrol.dragover">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.DragOver

**DragOver**(x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`, obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `DragItem.Types<dragitem.types>`) As `Boolean</api/data_types/boolean>`

> Fires when the `DragItem</api/user_interface/desktop/dragitem>` is over the <span class="title-ref">DesktopUIControl</span>.
>
> The *Obj* parameter is the object being dragged. The coordinates x and y are relative to the <span class="title-ref">DesktopUIControl</span>. Returns a `Boolean</api/data_types/boolean>`. Return `True</api/language/true>` from this event to prevent the drop from occurring.
>
> The *Action* parameter specifies the type of drag action, which is typically done by holding down a modifier key (Shift, Alt, Option, Command, etc.) while doing the drag.

<div id="desktopuicontrol.drawcontrolinlayouteditor">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.DrawControlInLayoutEditor

**DrawControlInLayoutEditor**(g As `Graphics</api/graphics/graphics>`)

> This event allows you to draw a preview of your control in the Layout Editor, similar to how the control will look like in at runtime. As this code will run as a script in the IDE, if it doesn't compile for any reason, you will see what happened in the Messages pane.
>
> This event fires whenever your control needs to be drawn in the Layout Editor.
>
> There is no need to re-open the project or restart the IDE, in order to see changes you make to the code in this event.
>
> For more information of how this works, see `Drawing Your Control<desktopuicontrol.drawing_your_control>`.

<div id="desktopuicontrol.dropobject">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.DropObject

**DropObject**(Obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `DragItem.Types<dragitem.types>`)

> The item represented by *Obj* has been dropped on the control.
>
> The *Obj* parameter is the object being dragged. The *Action* parameter specifies the type of drag action.
>
> The following DropObject event handler can handle either a dropped picture or a dropped file. The type of file that it can handle needs to have been specified in a call to AcceptFileDrop prior to the drop, for example, in the Opening event.
>
> ``` xojo
> If Obj.PictureAvailable Then
>   Me.Image = obj.Picture
> ElseIf Obj.FolderItemAvailable Then
>   Me.Image = Picture.Open(obj.FolderItem)
> End If
> ```

<div id="desktopuicontrol.focuslost">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.FocusLost

**FocusLost**

> The <span class="title-ref">DesktopUIControl</span> has lost the focus.
>
> This property must be set to `True</api/language/true>` for the <span class="title-ref">DesktopUIControl</span> to be capable of getting then losing the focus.
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> On macOS, controls other than text fields and lists will accept and lose focus only if the full keyboard access option is enabled in System Preferences/Keyboard.
>
> </div>

<div id="desktopuicontrol.focusreceived">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.FocusReceived

**FocusReceived**

> The <span class="title-ref">DesktopUIControl</span> has received the focus and has a selection rectangle around it.
>
> This property must be set to `True</api/language/true>` for the <span class="title-ref">DesktopUIControl</span> to be capable of getting the focus.
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> On macOS, controls other than text fields and lists will accept focus only if the full keyboard access option is enabled in System Preferences/Keyboard.
>
> </div>

<div id="desktopuicontrol.keydown">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.KeyDown

**KeyDown**(Key As `String</api/data_types/string>`) As `Boolean</api/data_types/boolean>`

> The user has pressed the *Key* passed while the `control</api/user_interface/desktop/desktopuicontrol>` has the focus.
>
> How KeyDown works depends on the type of control.
>
> **TextField and TextArea** Returning `True</api/language/true>` means the key is intercepted, preventing the key from actually reaching the control at all. This would be useful if you want to override the behavior of the tab key for example. Returning `False</api/language/false>` means the key reaches the control.
>
> **All Other Controls** Returning `True</api/language/true>` prevents the KeyDown event on the parent control (usually the window) from executing. Returning `False</api/language/false>` results in the execution of the KeyDown event of the parent control.

<div id="desktopuicontrol.keyup">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.KeyUp

**KeyUp**(Key As `String</api/data_types/string>`)

> Fires when the passed *Key* is released in the control that has the focus.
>
> It is not guaranteed to be the same key that received the KeyDown event.

<div id="desktopuicontrol.mousedown">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.MouseDown

**MouseDown**(X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`) As `Boolean</api/data_types/boolean>`

> The mouse button was pressed inside the control's region at the location passed in to *x*, *y*.
>
> This event fires repeatedly while the mouse button is being held down.
>
> The coordinates *x* and *y* are local to the control, i.e. they represent the position of the mouse click relative to the upper-left corner of the <span class="title-ref">DesktopUIControl</span>.
>
> `Return</api/language/return>` `True</api/language/true>` if you are going to handle the MouseDown. In such a case:
>
> - The Pressed event, if any, will not execute and the state of the object will not change.
> - You will receive the `MouseUp<desktopuicontrol.mouseup>` event.
>
> If you return `False</api/language/false>`, the system handles the MouseDown so the `MouseUp<desktopuicontrol.mouseup>` event handler does not get called.
>
> The MouseDown event uses the `DragItem</api/user_interface/desktop/dragitem>` constructor when the user drags the contents of the control. It is:
>
> ``` xojo
> Var d As DragItem
> d = New DragItem(Self, Me.Left, Me.Top, Me.Width, Me.Height)
> d.Picture = Me.Image
> d.Drag ' Allow the drag
> ```

<div id="desktopuicontrol.mousedrag">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.MouseDrag

**MouseDrag**(X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`)

> The mouse button was pressed inside the control and moved (dragged) at the location local to the control passed in to *x*, *y*.
>
> This event fires repeatedly while the mouse button is down regardless of whether or not the mouse coordinates are changing.
>
> This event will not occur unless you return `True</api/language/true>` in the MouseDown event.

<div id="desktopuicontrol.mouseenter">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.MouseEnter

**MouseEnter**

> The mouse has entered the area of the control.

<div id="desktopuicontrol.mouseexit">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.MouseExit

**MouseExit**

> The mouse has left the area of the control.

<div id="desktopuicontrol.mousemove">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.MouseMove

**MouseMove**(X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`)

> The mouse has moved within the control to the coordinates passed. The coordinates are local to the control, not to the window.

<div id="desktopuicontrol.mouseup">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.MouseUp

**MouseUp**(X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`)

> The mouse button was released. Use the *x* and *y* parameters to determine if the mouse button was released within the control's boundaries.
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> This event will not occur unless you return `True</api/language/true>` in the MouseDown event. The return value is ignored.
>
> </div>
>
> The parameters *x* and *y* are local coordinates, i.e. they represent the position of the mouse click relative to the upper-left corner of the <span class="title-ref">DesktopUIControl</span>. Mouse clicks that are released to the left or above a control are negative.

<div id="desktopuicontrol.mousewheel">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.MouseWheel

**MouseWheel**(X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`, DeltaX As `Integer</api/data_types/integer>`, DeltaY As `Integer</api/data_types/integer>`) As `Boolean</api/data_types/boolean>`

> The mouse wheel has been moved.
>
> The parameters *X* and *Y* are the mouse coordinates relative to the control that has received the event. The parameters *DeltaX* and *DeltaY* hold the number of scroll lines the wheel has been moved horizontally and vertically, as defined by the operating system. *DeltaX* is positive when the user scrolls right and negative when scrolling to the left. *DeltaY* is positive when the user scrolls down and negative when scrolling up.
>
> Returns a `Boolean</api/data_types/boolean>`. Return `True</api/language/true>` to prevent the event from propagating further.

<div id="desktopuicontrol.opening">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopUIControl.Opening

**Opening**

> The control is about to be displayed. Use this event to initialize a control.
>
> The Opening event is called after the Constructor.
>
> Be warned that initializing control property values using the Constructor instead of the Opening event may result in those property values being overwritten by what is set in the Inspector. For best results, use the Opening event for control initialization rather than the control Constructor.
>
> If the control is supposed to handle drag and drop, you need to tell it which type of item it needs to be able to handle. The following example informs the control that pictures and files can be dropped on it. The type of the file it needs to support is specified via the File Types Editor.
>
> ``` xojo
> Sub Opening()
>   Me.AcceptPictureDrop
>   Me.AcceptFileDrop("JPEG")
> End Sub
> ```

## Drawing Your Control

As for Xojo 2026r1 <span class="title-ref">DesktopUIControl</span> has the ability to draw itself in the Layout Editor using the same techniques that you use to draw a control in the Paint event of a Canvas control with one important difference: this event has access to the Properties and Constants of your class.

To draw a preview of your control in the Layout Editor, you must implement the DrawControlInLayoutEditor event. You may wish to implement it even if you're not using it to prevent this event from being available to the end users of your control. Most of the Xojo framework itself is not available in this event. If the code you have placed in the event can't compile or runs into a runtime issue, an amber warning icon will be drawn on your control and the errors will be displayed to the Messages pane.

<div class="important">

<div class="title">

Important

</div>

Methods cannot be called in this event.

</div>

Here's an example of how you would draw a red oval within the bounds of the control:

``` xojo
g.DrawingColor = Color.Red
g.DrawOval(0, 0, g.Width, g.Height)
```

In addition to the standard drawing controls, there are also some methods for accessing the properties and constants in your control.

### Property Methods

**BooleanProperty**(Name as String) as Boolean

> Gets the current value of a Boolean property of your control.

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

**ColorProperty**(name As `String</api/data_types/string>`) As `Color</api/data_types/color>`

> Gets the current value of a Color property of your control.

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

**DoubleProperty**(name As `String</api/data_types/string>`) As `Double</api/data_types/double>`

> Gets the current value of a Double property of your control.

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

**IntegerProperty**(name As `String</api/data_types/string>`) As `Integer</api/data_types/integer>`

> Gets the current value of an Integer property of your control.

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

**PictureProperty**(name As `String</api/data_types/string>`) As `Picture</api/graphics/picture>`

> Gets the current value of a Picture property of your control.

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

**StringProperty**(name As `String</api/data_types/string>`) As `String</api/data_types/string>`

> Gets the current value of a String property of your control.

### Constant Methods

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

**ConstantValue**(name As `String</api/data_types/string>`) As `String</api/data_types/string>`

> Gets the value of a constant in your control as a String.
>
> You can use the ConstantValue of a string stored in a constant, such as "kDescription".:
>
> ``` xojo
> Var s As String = ConstantValue("kDescription")
> g.DrawText(s, 25, 25)
> ```

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

**PictureConstant**(name As `String</api/data_types/string>`) As `Picture</api/graphics/picture>`

> Gets the value of a constant in your control as a Picture.
>
> You can use PictureConstant with the Base64 value (without the type header) of a picture stored in a constant, such as "kIcon":
>
> ``` xojo
> Var icon As Picture = PictureConstant("kIcon")
> g.DrawPicture(icon, 0, 0)
> ```

### Color Methods

**ColorGroup.NamedColor**(name As `String</api/data_types/string>`) As `Color</api/data_types/color>`

> When running on a platform that supports named colors (only macOS at the time of this writing), this method returns the named OS.
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> Color names are case sensitive, so the macOS secondary label color should be "secondaryLabelColor".
>
> </div>

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

**TextColor** As `Color</api/data_types/color>`

> Returns the current text color of the platform that the IDE is running on.

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

**FillColor** As `Color</api/data_types/color>`

> Returns the current fill color of the platform that the IDE is running on.

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

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

> Returns `True</api/language/true>` if the system is running in dark mode (only macOS at the time of this writing).

### Font Methods

**FontCount** As `Integer</api/data_types/integer>`

> Returns the number of fonts available on the system.

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

**FontAt**(index As `Integer</api/data_types/integer>`) As `String</api/data_types/string>`

> Returns the name of the font at the specified *index*.

### Other Methods

**DebugLog**(msg As `String</api/data_types/string>`)

> Sends *msg* to the Messages pane.

**Print**(msg As `String</api/data_types/string>`)

> Sends *msg* to the Messages pane.

## Notes

Most visual controls inherit the properties of the <span class="title-ref">DesktopUIControl</span>. A <span class="title-ref">DesktopUIControl</span> cannot be created or modified directly. Instead, you create and modify the <span class="title-ref">DesktopUIControl</span> subclasses like `DesktopButtons</api/user_interface/desktop/desktopbutton>`, `DesktopTextFields</api/user_interface/desktop/desktoptextfield>`, `DesktopListBoxes</api/user_interface/desktop/desktoplistbox>`, etc.

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

### The control hierarchy

In some cases you build portions of your interface by placing some controls within another control. For example, you use the `GroupBox</api/user_interface/desktop/desktopgroupbox>` control to organize other controls, usually `RadioGroup</api/user_interface/desktop/desktopradiogroup>` or possibly `CheckBoxes</api/user_interface/desktop/desktopcheckbox>`. The `TabPanel</api/user_interface/desktop/desktoptabpanel>` and `PagePanel</api/user_interface/desktop/desktoppagepanel>` controls also designed to enclose other controls.

The control that encloses the others is known as the parent control and the controls that are entirely within its borders are the child controls. This works automatically if you create the controls in the order of: parent-child. That is, create the control that encloses the others first, then create the child controls or duplicate existing child controls and keep them inside the parent control.

You can use the `Parent<desktopuicontrol.parent>` property of the <span class="title-ref">DesktopUIControl</span> class to either get or set the parent of an existing control. If you create a child control before its parent, you can set its parent using its `Parent<desktopuicontrol.parent>` property.

If a control is not completely enclosed by another control then it doesn't automatically become a child; it overlaps the other control.

If you move a child outside its parent, it is no longer a child of that control. If you move it completely inside another control, it becomes the child of that control.

When you copy a parent control, you copy all its child controls as well.

You can create more than one level of nesting. For example, you can place a `GroupBox</api/user_interface/desktop/desktopgroupbox>` within a `TabPanel</api/user_interface/desktop/desktoptabpanel>` and then place a `RadioGroup</api/user_interface/desktop/desktopradiogroup>` within the `GroupBox</api/user_interface/desktop/desktopgroupbox>`. In this case, the `GroupBox</api/user_interface/desktop/desktopgroupbox>` is the parent of the `RadioGroup</api/user_interface/desktop/desktopradiogroup>` and the `TabPanel</api/user_interface/desktop/desktoptabpanel>` is the parent of the `GroupBox</api/user_interface/desktop/desktopgroupbox>`. To make this work automatically, you must create them in the order that respects the hierarchy: first create the `TabPanel</api/user_interface/desktop/desktoptabpanel>`, then the `GroupBox</api/user_interface/desktop/desktopgroupbox>`, and then the `RadioGroup</api/user_interface/desktop/desktopradiogroup>`.

Obviously, the parent control must be in the same window as its child controls. If you attempt to get the parent of a control whose parent is in another window, you will get an `InvalidParentException</api/exceptions/invalidparentexception>` error.

If a control is not enclosed by another control, then its “parent” is its window.

If a control is enclosed by another control, but you don't want it to behave as a child, then set its `Parent<desktopuicontrol.parent>` property to `Nil</api/language/nil>`. This will cause the control's Parent to become the window.

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

### Control hierarchy features

To take advantage of the features of the control hierarchy automatically, create the parent control first and then add the child controls by dragging fully into the interior of the parent control. When you add a child to a parent in this manner, a marquee surrounds the parent. A marquee also surrounds the parent control whenever you select an existing child control. You can disable the marquee in Preferences/Options.

If you duplicate a child control and leave the duplicate within the parent, then it is automatically a child. However, if you move the duplicate outside the parent, it is no longer a child. A control must be fully enclosed by the parent to be considered a child.

In the following example, both `` TextField</api/user_interface/desktop/desktoptextfield>`s report the identity of their parents. The bottom one was duplicated from the top one but has been moved out of the :doc:`TabPanel</api/user_interface/desktop/desktoptabpanel> ``. It is no longer a child.

> ![image](images/desktopuicontrol_parented_control.png)
>
> ![image](images/desktopuicontrol_unparented_control.png)

When you move a child out of the'scope' of the parent, the marquee surrounding the parent is turned off, indicating that the child is not under parental control anymore.

If you move the bottom `TextField</api/user_interface/desktop/desktoptextfield>` back within the `TabPanel</api/user_interface/desktop/desktoptabpanel>`, it becomes a child of the `TabPanel</api/user_interface/desktop/desktoptabpanel>` once again.

Moving a parent control moves its child controls as well. In the following example, the `TabPanel</api/user_interface/desktop/desktoptabpanel>` shown above was moved down. It takes the top `TextField</api/user_interface/desktop/desktoptextfield>` with it, but leaves the bottom one orphaned.

> ![image](images/desktopuicontrol_moving_parented_controls.png)

- Deleting a parent control deletes all child controls.
- Hiding a parent hides all child controls, but retains the previous visibility status of all children.
- Showing a parent control shows only the child controls whose visibility is set.
- Disabling a parent control disables all its child controls, but retains the previous visibility status of all children. In the IDE, disabling a container visually disables all the child controls, but does not update the Enabled property.
- Disabling the `TabPanel</api/user_interface/desktop/desktoptabpanel>` disables all child controls, as expected.

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

### Dragging

There are three possible items a user can drag from a control: text, a picture, and/or a `FolderItem</api/files/folderitem>`. In order for the user to be able to drag, the control must create a `DragItem</api/user_interface/desktop/dragitem>` object in the appropriate event handler. The appropriate event handler depends on the type of object. For example, the appropriate event handler for a `DesktopCanvas</api/user_interface/desktop/desktopcanvas>` control is the MouseDown event handler since the user must be holding down the mouse button to drag.

The `DragItem</api/user_interface/desktop/dragitem>` object represents the data that the user is dragging. `DragItem</api/user_interface/desktop/dragitem>` objects have properties to hold text, pictures, and `folderItems</api/files/folderitem>`. One or more of these properties must be populated with the values the user wishes to drag. When you create a new `DragItem</api/user_interface/desktop/dragitem>` object using the `DragItem</api/user_interface/desktop/dragitem>` constructor, you specify the drag rectangle that will appear as the user drags from the control.

`TextFields</api/user_interface/desktop/desktoptextfield>`, `TextAreas</api/user_interface/desktop/desktoptextarea>`, and `ListBoxes</api/user_interface/desktop/desktoplistbox>` have implicit dragging built in to them. This means that they will create a new `DragItem</api/user_interface/desktop/dragitem>` and drag rectangle for you. `TextFields</api/user_interface/desktop/desktoptextfield>` and `TextAreas</api/user_interface/desktop/desktoptextarea>` automatically populate the Text property of the `DragItem</api/user_interface/desktop/dragitem>` with the text the user is dragging. `ListBoxes</api/user_interface/desktop/desktoplistbox>` have a DragRow event handler where you can populate the `DragItem</api/user_interface/desktop/dragitem>` with the data to be dragged.

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

### Dropping

Before a control will accept an item being dropped on it, you must call the `AcceptFileDrop<desktopuicontrol.acceptfiledrop>`, `AcceptPictureDrop<desktopuicontrol.acceptpicturedrop>`, `AcceptRawDataDrop<desktopuicontrol.acceptrawdatadrop>`, and/or `AcceptTextDrop<desktopuicontrol.accepttextdrop>` methods to indicate the drop types that will be allowed. This is usually done in the control's `Opening<desktopcontrol.opening>` event handler. When an acceptable item is dropped on the control, the control's `DropObject<desktopuicontrol.dropobject>` event handler will execute and will be passed the `DragItem</api/user_interface/desktop/dragitem>` that has been dropped on the control. At that point you can use the `DragItem's</api/user_interface/desktop/dragitem>` methods to determine what kind of data is available and access it. If you are only allowing a particular type of drag data (text for example) then there would be no need to test the type of data that is being dragged. You can get the text from the `Text<dragitem.text>` property of the `DragItem</api/user_interface/desktop/dragitem>`.

To restrict file drops to specific file types on macOS, in addition to creating a File Type (as a `project item</getting_started/using_the_ide/file_type_group_editor>` or `via code</api/files/filetype>`) to define the file extension, you must also use the `DragEnter<desktopuicontrol.dragenter>` event:

> For example, to restrict drops to folders only:
>
> ``` xojo
> If Not obj.FolderItem.IsFolder Then Return True
> ```
>
> To restrict drops to a files with a specific extension:
>
> ``` xojo
> If Not obj.FolderItem.Extension <> ".my_extension" Then Return True
> ```

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

### Handling contextual menus

The following code in a `ConstructContextualMenu<desktopuicontrol.constructcontextualmenu>` event builds a simple contextual menu. The parameter *Base* as `DesktopMenuItem</api/user_interface/desktop/desktopmenuitem>` is passed in as a parameter.

``` xojo
base.AddMenu(New DesktopMenuItem("Import"))
base.AddMenu(New DesktopMenuItem("Export"))
Return True  //display the contextual menu
```

The following `Select Case</api/language/select_case>` statement in the `ContextualMenuItemSelected<desktopuicontrol.contextualmenuitemselected>` event handler inspects the selected menu item, which is passed in as the *HitItem* as `DesktopMenuItem</api/user_interface/desktop/desktopmenuitem>` parameter.

``` xojo
Select Case hitItem.Text
Case "Import"
  MessageBox("You chose Import")
Case "Export"
  MessageBox("You chose export")
End Select

Return True
```

On macOS, standard controls no longer filter contextual clicks. This responsibility can always be overridden by you in the MouseDown event for the control.

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

### Changing the cursor

The MouseCursor property controls which cursor will be displayed while the mouse is within the control, assuming that the MouseCursor properties of the `DesktopApplication</api/user_interface/desktop/desktopapplication>` and parent `DesktopWindow</api/user_interface/desktop/desktopwindow>` classes are `Nil</api/language/nil>`. You can, for example, assign different MouseCursors to different controls within a window and the shape of the pointer will change whenever it is over a particular control. The `Cursors</api/user_interface/desktop/cursors>` module contains a library of custom cursors that you access with the syntax `System.Cursors<system.cursors>`.MouseCursorName. Please see the `MouseCursor</api/user_interface/desktop/mousecursor>` class for information about the library of custom cursors.

If you also need custom cursors at the Window or Application levels, you need to manage them along the lines described in the section on the `MouseCursor</api/user_interface/desktop/mousecursor>` class.

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

### Custom cursors in windows

If you need to use custom cursors in the Windows build of your application, you can do so using a slightly modified version of this technique.

1.  With a resource editor, create a CURS resource that contains only one cursor. Give the resource file a name that indicates the type of cursor contained in the resource file.
2.  Repeat this process for each custom cursor.
3.  Add all the resource files to the Project Editor.
4.  You can then access each custom cursor by name, e.g.

``` xojo
Me.MouseCursor = Pen
```

## Sample code

This example shows how the DropObject event handler of a `DesktopTextArea</api/user_interface/desktop/desktoptextarea>` (named TextArea1 in this example) would be coded to handle one or more text documents or some text being dropped on it:

``` xojo
Sub DropObject(Obj As DragItem, action As Integer)
If Obj.TextAvailable Then
  TextArea1.Text = Obj.Text
ElseIf Obj.FolderItemAvailable Then
  Do
    ' Load the styled text from the document
    ' into TextArea1
    If Not TextArea1.Open(Obj.FolderItem) Then
      MessageBox("Drag Failed")
    End If
    Loop Until Not Obj.NextItem
End If
```

## Compatibility

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

<div class="seealso">

`DesktopControl</api/user_interface/desktop/desktopcontrol>` parent class

</div>
