<div class="meta" robots="noindex">

</div>

Class

# Control

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

<div class="warning">

<div class="title">

Warning

</div>

This item was deprecated in version 2021r3. Please use `DesktopControl</api/user_interface/desktop/desktopcontrol>` as a replacement.

</div>

## Description

The base class for all controls. The `RectControl</api/deprecated/rectcontrol>` class is subclassed from the <span class="title-ref">Control</span> class.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                             | Type                               | Read-Only | Shared |
|----------------------------------|------------------------------------|-----------|--------|
| `Handle<control.handle>`         | `Integer</api/data_types/integer>` | ✓         |        |
| `Index<control.index>`           | `Integer</api/data_types/integer>` | ✓         |        |
| `MouseX<control.mousex>`         | `Integer</api/data_types/integer>` | ✓         |        |
| `MouseY<control.mousey>`         | `Integer</api/data_types/integer>` | ✓         |        |
| `Name<control.name>`             | `String</api/data_types/string>`   | ✓         |        |
| `PanelIndex<control.panelindex>` | `Integer</api/data_types/integer>` |           |        |
| `Scope<control.scope>`           | `Integer</api/data_types/integer>` | ✓         |        |
| `Window<control.window>`         | `Window</api/deprecated/window>`   | ✓         |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                          | Parameters | Returns | Shared |
|-------------------------------|------------|---------|--------|
| `Close<control.close_method>` |            |         |        |

## Events

<div class="rst-class">

table-centered_column_4

</div>

| Name                         | Parameters | Returns |
|------------------------------|------------|---------|
| `Close<control.close_event>` |            |         |
| `Open<control.open>`         |            |         |

## Property descriptions

<div id="control.handle">

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

</div>

<div class="rst-class">

forsearch

</div>

Control.Handle

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

Returns a handle to the <span class="title-ref">Control</span>.

This property is read-only.

For interfacing with Mac APIs using `` Declare</api/language/declare>`s, RectControl.Handle returns NSViews (except for :doc:`Toolbar</api/deprecated/toolbar> ``).

On Windows returns the HWND of the <span class="title-ref">Control</span>.

On Linux it returns a GtkWidget.

The following gets a handle to the <span class="title-ref">Control</span>.

``` xojo
Var i As Integer = Me.Handle
```

<div id="control.index">

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

</div>

<div class="rst-class">

forsearch

</div>

Control.Index

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

If the <span class="title-ref">Control</span> is used in a <span class="title-ref">Control</span> set, this specifies the <span class="title-ref">Control</span>'s index in the set.

This property is read-only.

The *control set* is often used to manage a group of RadioButtons since a single RadioButton in a window doesn't make much sense. Most typically, you create an instance of the RadioButton, assign 0 to its Index property, and then duplicate it. This increments the value of Index for each new instance but retain the original <span class="title-ref">Control</span>'s name.

To determine which RadioButton the user clicked, use the Action event handler of the <span class="title-ref">Control</span> set. The parameter *Index* contains the value of Index for the RadioButton that was clicked. The event handler is this:

``` xojo
Sub Action(Index As Integer)
  Label1.Text = "You chose radio button " + index.ToString + "."
End Sub
```

To set a RadioButton in a <span class="title-ref">Control</span> set, you use its *Index* property to refer to the RadioButton whose value you want to set. For example, the following line selects the second RadioButton from code:

``` xojo
RadioButton1(1).Value = True ' 0-based
```

<div id="control.mousex">

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

</div>

<div class="rst-class">

forsearch

</div>

Control.MouseX

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

The X coordinate of the mouse (points). Measured from the top-left corner of the <span class="title-ref">Control</span>.

This property is read-only.

This code is in the MouseDown event of a `TextField</api/deprecated/textfield>` and displays the X-coordinate at the point of the MouseDown event.

``` xojo
Me.Value = Str(Me.MouseX)
```

<div id="control.mousey">

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

</div>

<div class="rst-class">

forsearch

</div>

Control.MouseY

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

The Y coordinate of the mouse (points). Measured from the top-left corner of the <span class="title-ref">Control</span>.

This property is read-only.

This code is in the MouseDown event of a `TextField</api/deprecated/textfield>` and displays the Y-coordinate at the point of the MouseDown event.

``` xojo
Me.Value = Str(Me.MouseY)
```

<div id="control.name">

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

</div>

<div class="rst-class">

forsearch

</div>

Control.Name

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

The name of the <span class="title-ref">Control</span>. Set the name of the <span class="title-ref">Control</span> in the Inspector.

This property is read-only.

<div id="control.panelindex">

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

</div>

<div class="rst-class">

forsearch

</div>

Control.PanelIndex

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

If the <span class="title-ref">Control</span> has been placed on a `TabPanel</api/deprecated/tabpanel>` or `PagePanel</api/deprecated/pagepanel>` <span class="title-ref">Control</span>, this is the panel (page/tab) that the <span class="title-ref">Control</span> is on. If the <span class="title-ref">Control</span> is not on a panel, it returns -1.

The first panel is numbered zero. If the <span class="title-ref">Control</span> has been placed on a panel of a `TabPanel</api/deprecated/tabpanel>` or `PagePanel</api/deprecated/pagepanel>` <span class="title-ref">Control</span>, it returns the panel number. If the <span class="title-ref">Control</span> is not on a `PagePanel</api/deprecated/pagepanel>` or `TabPanel</api/deprecated/tabpanel>`, it returns -1. If you change the PanelIndex to a nonexistent panel, the <span class="title-ref">Control</span> 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 `PagePanel.SelectedPanelIndex<pagepanel.selectedpanelindex>`.

This code displays the panel index of the <span class="title-ref">Control</span> that is on the page.

``` xojo
Label3.Value = Str(Me.PanelIndex)
```

<div id="control.scope">

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

</div>

<div class="rst-class">

forsearch

</div>

Control.Scope

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

Used to determine whether access to the <span class="title-ref">Control</span> is Public (0) or Private (2). The default is Public.

This property is read-only.

If the Scope of a <span class="title-ref">Control</span> is set to Private, it cannot be accessed from outside its parent window.

<div id="control.window">

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

</div>

<div class="rst-class">

forsearch

</div>

Control.Window

**Window** As `Window</api/deprecated/window>`

The <span class="title-ref">Control</span>'s parent window.

This property is read-only.

This code gets the parent window's Title property.

``` xojo
TextField1.Text = Me.Window.Title
```

## Method descriptions

<div id="control.close_method">

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

</div>

<div class="rst-class">

forsearch

</div>

Control.Close

**Close**

Closes a <span class="title-ref">Control</span>.

Closing a <span class="title-ref">Control</span> permanently removes the <span class="title-ref">Control</span> from memory, making it impossible to access. You can close both non-indexed controls and indexed controls. When you close an indexed <span class="title-ref">Control</span>, the indexes for the remaining controls will shift downward so that the indexes start with zero and are consecutive.

The following code closes the <span class="title-ref">Control</span>. When this is executed from a visible <span class="title-ref">Control</span>, the <span class="title-ref">Control</span> disappears from the window.

``` xojo
Me.Close
```

## Event descriptions

<div id="control.close_event">

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

</div>

<div class="rst-class">

forsearch

</div>

Control.Close

**Close**

The <span class="title-ref">Control</span> is about to close.

<div id="control.open">

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

</div>

<div class="rst-class">

forsearch

</div>

Control.Open

**Open**

The <span class="title-ref">Control</span> is about to be displayed. Use this event to initialize a <span class="title-ref">Control</span>.

The Open event is called after the Constructor.

Be warned that initializing <span class="title-ref">Control</span> property values using the Constructor instead of the Open event may result in those property values being overwritten by what is set in the Inspector. For best results, use the Open event for <span class="title-ref">Control</span> initialization rather than the <span class="title-ref">Control</span> Constructor.

If the <span class="title-ref">Control</span> 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 <span class="title-ref">Control</span> 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 Open()
  Me.AcceptPictureDrop
  Me.AcceptFileDrop("JPEG")
End Sub
```

## Compatibility

All project types on all supported operating systems.

## See also

`Object</api/data_types/additional_types/object>` parent class; `NotePlayer</api/deprecated/noteplayer>` control; `Object</api/data_types/additional_types/object>`, `RectControl</api/deprecated/rectcontrol>`, `DesktopContainer</api/user_interface/desktop/desktopcontainer>` classes.
