Class

# DesktopTextControl

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

## Description

The base class for `DesktopTextField</api/user_interface/desktop/desktoptextfield>` and `DesktopTextArea</api/user_interface/desktop/desktoptextarea>`.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                                                    | Type                                                       | Read-Only | Shared |
|-------------------------------------------------------------------------|------------------------------------------------------------|-----------|--------|
| `Active<desktoptextcontrol.active>`                                     | `Boolean</api/data_types/boolean>`                         | ✓         |        |
| `AllowAutoDeactivate<desktoptextcontrol.allowautodeactivate>`           | `Boolean</api/data_types/boolean>`                         |           |        |
| `AllowFocusRing<desktoptextcontrol.allowfocusring>`                     | `Boolean</api/data_types/boolean>`                         |           |        |
| `AllowSpellChecking<desktoptextcontrol.allowspellchecking>`             | `Boolean</api/data_types/boolean>`                         |           |        |
| `AllowTabs<desktoptextcontrol.allowtabs>`                               | `Boolean</api/data_types/boolean>`                         |           |        |
| `AllowTabStop<desktoptextcontrol.allowtabstop>`                         | `Boolean</api/data_types/boolean>`                         |           |        |
| `BackgroundColor<desktoptextcontrol.backgroundcolor>`                   | `ColorGroup</api/graphics/colorgroup>`                     |           |        |
| `Bold<desktoptextcontrol.bold>`                                         | `Boolean</api/data_types/boolean>`                         |           |        |
| `Enabled<desktoptextcontrol.enabled>`                                   | `Boolean</api/data_types/boolean>`                         |           |        |
| `FontName<desktoptextcontrol.fontname>`                                 | `String</api/data_types/string>`                           |           |        |
| `FontSize<desktoptextcontrol.fontsize>`                                 | `Single</api/data_types/single>`                           |           |        |
| `FontUnit<desktoptextcontrol.fontunit>`                                 | `FontUnits</api/graphics/fontunits>`                       |           |        |
| `Format<desktoptextcontrol.format>`                                     | `String</api/data_types/string>`                           |           |        |
| `FormattedText<desktoptextcontrol.formattedtext>`                       | `String</api/data_types/string>`                           | ✓         |        |
| `Handle<desktoptextcontrol.handle>`                                     | `Ptr</api/data_types/additional_types/ptr>`                | ✓         |        |
| `HasBorder<desktoptextcontrol.hasborder>`                               | `Boolean</api/data_types/boolean>`                         |           |        |
| `Height<desktoptextcontrol.height>`                                     | `Integer</api/data_types/integer>`                         |           |        |
| `HorizontalScrollPosition<desktoptextcontrol.horizontalscrollposition>` | `Integer</api/data_types/integer>`                         |           |        |
| `Index<desktoptextcontrol.index>`                                       | `Integer</api/data_types/integer>`                         |           |        |
| `Italic<desktoptextcontrol.italic>`                                     | `Boolean</api/data_types/boolean>`                         |           |        |
| `Left<desktoptextcontrol.left>`                                         | `Integer</api/data_types/integer>`                         |           |        |
| `LockBottom<desktoptextcontrol.lockbottom>`                             | `Boolean</api/data_types/boolean>`                         |           |        |
| `LockLeft<desktoptextcontrol.lockleft>`                                 | `Boolean</api/data_types/boolean>`                         |           |        |
| `LockRight<desktoptextcontrol.lockright>`                               | `Boolean</api/data_types/boolean>`                         |           |        |
| `LockTop<desktoptextcontrol.locktop>`                                   | `Boolean</api/data_types/boolean>`                         |           |        |
| `MouseCursor<desktoptextcontrol.mousecursor>`                           | `MouseCursor</api/user_interface/desktop/mousecursor>`     |           |        |
| `Name<desktoptextcontrol.name>`                                         | `String</api/data_types/string>`                           | ✓         |        |
| `PanelIndex<desktoptextcontrol.panelindex>`                             | `Integer</api/data_types/integer>`                         |           |        |
| `Parent<desktoptextcontrol.parent>`                                     | `Object</api/data_types/additional_types/object>`          |           |        |
| `ReadOnly<desktoptextcontrol.readonly>`                                 | `Boolean</api/data_types/boolean>`                         |           |        |
| `Scope<desktoptextcontrol.scope>`                                       | `Integer</api/data_types/integer>`                         | ✓         |        |
| `SelectedText<desktoptextcontrol.selectedtext>`                         | `String</api/data_types/string>`                           |           |        |
| `SelectionLength<desktoptextcontrol.selectionlength>`                   | `Integer</api/data_types/integer>`                         |           |        |
| `SelectionStart<desktoptextcontrol.selectionstart>`                     | `Integer</api/data_types/integer>`                         |           |        |
| `TabIndex<desktoptextcontrol.tabindex>`                                 | `Integer</api/data_types/integer>`                         |           |        |
| `Text<desktoptextcontrol.text>`                                         | `String</api/data_types/string>`                           |           |        |
| `TextAlignment<desktoptextcontrol.textalignment>`                       | `TextAlignments</api/text/textalignments>`                 |           |        |
| `TextColor<desktoptextcontrol.textcolor>`                               | `ColorGroup</api/graphics/colorgroup>`                     |           |        |
| `Tooltip<desktoptextcontrol.tooltip>`                                   | `String</api/data_types/string>`                           |           |        |
| `Top<desktoptextcontrol.top>`                                           | `Integer</api/data_types/integer>`                         |           |        |
| `Transparent<desktoptextcontrol.transparent>`                           | `Boolean</api/data_types/boolean>`                         |           |        |
| `Underline<desktoptextcontrol.underline>`                               | `Boolean</api/data_types/boolean>`                         |           |        |
| `ValidationMask<desktoptextcontrol.validationmask>`                     | `String</api/data_types/string>`                           |           |        |
| `Visible<desktoptextcontrol.visible>`                                   | `Boolean</api/data_types/boolean>`                         |           |        |
| `Width<desktoptextcontrol.width>`                                       | `Integer</api/data_types/integer>`                         |           |        |
| `Window<desktoptextcontrol.window>`                                     | `DesktopWindow</api/user_interface/desktop/desktopwindow>` | ✓         |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                                      | Parameters                                                                                                                                                                                                                                                    | Returns                            | Shared |
|-----------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------|--------|
| `AcceptFileDrop<desktoptextcontrol.acceptfiledrop>`       | FileType As `String</api/data_types/string>`                                                                                                                                                                                                                  |                                    |        |
| `AcceptPictureDrop<desktoptextcontrol.acceptpicturedrop>` |                                                                                                                                                                                                                                                               |                                    |        |
| `AcceptRawDataDrop<desktoptextcontrol.acceptrawdatadrop>` | Type As `String</api/data_types/string>`                                                                                                                                                                                                                      |                                    |        |
| `AcceptTextDrop<desktoptextcontrol.accepttextdrop>`       |                                                                                                                                                                                                                                                               |                                    |        |
| `AddText<desktoptextcontrol.addtext>`                     | text As `String</api/data_types/string>`                                                                                                                                                                                                                      |                                    |        |
| `CharacterPosition<desktoptextcontrol.characterposition>` | LineNumber As `Integer</api/data_types/integer>`                                                                                                                                                                                                              | `Integer</api/data_types/integer>` |        |
|                                                           | X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`                                                                                                                                                                              | `Integer</api/data_types/integer>` |        |
| `Close<desktoptextcontrol.close>`                         |                                                                                                                                                                                                                                                               |                                    |        |
| `Copy<desktoptextcontrol.copy>`                           |                                                                                                                                                                                                                                                               |                                    |        |
| `DrawInto<desktoptextcontrol.drawinto>`                   | g As `Graphics</api/graphics/graphics>`, x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`                                                                                                                                     |                                    |        |
| `InsertionPosition<desktoptextcontrol.insertionposition>` | X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`                                                                                                                                                                              | `Integer</api/data_types/integer>` |        |
| `LineNumber<desktoptextcontrol.linenumber>`               | CharPosition As `Integer</api/data_types/integer>`                                                                                                                                                                                                            | `Integer</api/data_types/integer>` |        |
| `Paste<desktoptextcontrol.paste>`                         |                                                                                                                                                                                                                                                               |                                    |        |
| `Refresh<desktoptextcontrol.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>` |                                    |        |
| `SelectAll<desktoptextcontrol.selectall>`                 |                                                                                                                                                                                                                                                               |                                    |        |
| `SetFocus<desktoptextcontrol.setfocus>`                   |                                                                                                                                                                                                                                                               |                                    |        |

## Events

<div class="rst-class">

table-centered_column_4

</div>

| Name                                                                        | Parameters                                                                                                                                                                            | Returns                            |
|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------|
| `Closing<desktoptextcontrol.closing>`                                       |                                                                                                                                                                                       |                                    |
| `ConstructContextualMenu<desktoptextcontrol.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<desktoptextcontrol.contextualmenuitemselected>` | HitItem As `DesktopMenuItem</api/user_interface/desktop/desktopmenuitem>`                                                                                                             | `Boolean</api/data_types/boolean>` |
| `DragEnter<desktoptextcontrol.dragenter>`                                   | obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `DragItem.Types<dragitem.types>`                                                                                   | `Boolean</api/data_types/boolean>` |
| `DragExit<desktoptextcontrol.dragexit>`                                     | obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `DragItem.Types<dragitem.types>`                                                                                   |                                    |
| `DragOver<desktoptextcontrol.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>` |
| `DropObject<desktoptextcontrol.dropobject>`                                 | obj As `DragItem</api/user_interface/desktop/dragitem>`, action As `DragItem.Types<dragitem.types>`                                                                                   |                                    |
| `FocusLost<desktoptextcontrol.focuslost>`                                   |                                                                                                                                                                                       |                                    |
| `FocusReceived<desktoptextcontrol.focusreceived>`                           |                                                                                                                                                                                       |                                    |
| `KeyDown<desktoptextcontrol.keydown>`                                       | Key As `String</api/data_types/string>`                                                                                                                                               | `Boolean</api/data_types/boolean>` |
| `KeyUp<desktoptextcontrol.keyup>`                                           | Key As `String</api/data_types/string>`                                                                                                                                               |                                    |
| `MenuBarSelected<desktoptextcontrol.menubarselected>`                       |                                                                                                                                                                                       |                                    |
| `MouseDown<desktoptextcontrol.mousedown>`                                   | X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`                                                                                                      | `Boolean</api/data_types/boolean>` |
| `MouseDrag<desktoptextcontrol.mousedrag>`                                   | X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`                                                                                                      |                                    |
| `MouseEnter<desktoptextcontrol.mouseenter>`                                 |                                                                                                                                                                                       |                                    |
| `MouseExit<desktoptextcontrol.mouseexit>`                                   |                                                                                                                                                                                       |                                    |
| `MouseMove<desktoptextcontrol.mousemove>`                                   | X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`                                                                                                      |                                    |
| `MouseUp<desktoptextcontrol.mouseup>`                                       | X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`                                                                                                      |                                    |
| `MouseWheel<desktoptextcontrol.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<desktoptextcontrol.opening>`                                       |                                                                                                                                                                                       |                                    |
| `SelectionChanged<desktoptextcontrol.selectionchanged>`                     |                                                                                                                                                                                       |                                    |
| `TextChanged<desktoptextcontrol.textchanged>`                               |                                                                                                                                                                                       |                                    |
| `ValidationFailed<desktoptextcontrol.validationfailed>`                     | InvalidText As `String</api/data_types/string>`, StartPosition As `Integer</api/data_types/integer>`                                                                                  |                                    |

## Property descriptions

<div id="desktoptextcontrol.active">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.Active

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

> Indicates whether the `control</api/user_interface/desktop/desktopuicontrol>` 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="desktoptextcontrol.allowautodeactivate">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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="desktoptextcontrol.allowfocusring">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.AllowFocusRing

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

> If `True</api/language/true>`, the control indicates that it has the focus with a ring around its border; if `False</api/language/false>`, the appearance of the control does not change when it has the focus.
>
> This example is in the Opening event of the control:
>
> ``` xojo
> Me.AllowFocusRing = False
> ```

<div id="desktoptextcontrol.allowspellchecking">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.AllowSpellChecking

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

> If `True</api/language/true>`, words that are believed to be misspelled are underlined.
>
> This example is in the Opening event of a TextArea:
>
> ``` xojo
> Me.AllowSpellChecking = True  
> ```

<div id="desktoptextcontrol.allowtabs">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.AllowTabs

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

> If `True</api/language/true>`, pressing the Tab key will enter a tab into the control instead of moving the focus to the next item in the tab order.

<div id="desktoptextcontrol.allowtabstop">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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="desktoptextcontrol.backgroundcolor">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.BackgroundColor

**BackgroundColor** As `ColorGroup</api/graphics/colorgroup>`

> The background color for the control.
>
> This code sets the value of the BackgroundColor property:
>
> ``` xojo
> Me.BackgroundColor = Color.Red
> ```

<div id="desktoptextcontrol.bold">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.Bold

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

> If `True</api/language/true>`, applies the bold style to the control's text.
>
> Mac apps can only display font styles that are available. You cannot force a font to display in bold or italic if it does not have bold or italic variations available. In this situation, the Bold property will not affect the font.
>
> This example sets the text to Bold.
>
> ``` xojo
> Me.Bold = True
> ```

<div id="desktoptextcontrol.enabled">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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="desktoptextcontrol.fontname">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.FontName

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

> Name of the font used to display the text content.
>
> You can enter any font that is installed on the computer or the names of the two metafonts, "System" and "SmallSystem".
>
> The System font is the font used by the system software as its default font. Different operating systems use different default fonts. If the system software supports both a large and small System font, you can also specify the "SmallSystem" font as your TextFont.
>
> On macOS, "SmallSystem" specifies the OS's smaller system font and may make the control smaller in size as well. On Windows and Linux, "SmallSystem" is the same as "System".
>
> This code sets the FontName property.
>
> ``` xojo
> Me.FontName = "Helvetica"
> ```

<div id="desktoptextcontrol.fontsize">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.FontSize

**FontSize** As `Single</api/data_types/single>`

> Point size of the font used to display text content of a `DesktopControl</api/user_interface/desktop/desktopcontrol>`.
>
> If you enter zero as the FontSize, your app will use the font size that works best for the platform on which it is running.
>
> This code sets the font size to 16 points.
>
> ``` xojo
> Me.FontSize = 16
> ```

<div id="desktoptextcontrol.fontunit">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.FontUnit

**FontUnit** As `FontUnits</api/graphics/fontunits>`

> The units in which FontSize is measured.
>
> See the `FontUnits</api/graphics/fontunits>` enumeration for valid values.
>
> This example is in the Opening event of the control. It sets the font unit to Pixel.
>
> ``` xojo
> Me.FontUnit = FontUnits.Pixel
> ```

<div id="desktoptextcontrol.format">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.Format

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

> Formats the contents of the control when it loses the focus.
>
> It uses the same formatting conventions as the `Format</api/text/format>` function. To turn off formatting, set the Format property to the empty string, "".
>
> If you need to enforce an entry format rather than permitting any entry, use the Format property in conjunction with the ValidationMask property. See the description of the `ValidationMask<desktoptextcontrol.validationmask>` property and the section "Masks" in the Notes section.
>
> This line applies a dollar format when the user tabs out of the field.
>
> ``` xojo
> Me.Format = "\$###,###.##"
> ```

<div id="desktoptextcontrol.formattedtext">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.FormattedText

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

> Returns the Text property formatted using the value in the `Format<desktoptextcontrol.format>` property.
>
> This property is read-only.

<div id="desktoptextcontrol.handle">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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="desktoptextcontrol.hasborder">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.HasBorder

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

> Indicates whether or not the border is visible.

<div id="desktoptextcontrol.height">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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="desktoptextcontrol.horizontalscrollposition">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.HorizontalScrollPosition

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

> Scrolls the text control horizontally to the position (in points) from the left edge of the control.
>
> This code scrolls the control horizontally by 200 points.
>
> ``` xojo
> TextArea1.HorizontalScrollPosition = 200
> ```

<div id="desktoptextcontrol.index">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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="desktoptextcontrol.italic">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.Italic

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

> If `True</api/language/true>`, applies the italic style to the control's text.
>
> Mac apps can only display font styles that are available. You cannot force a font to display in bold or italic if it does not have bold or italic variations available. In this situation, the Italic property will not affect the font.
>
> The following sets the Italic property for the control.
>
> ``` xojo
> Me.Italic = True
> ```

<div id="desktoptextcontrol.left">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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="desktoptextcontrol.lockbottom">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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="desktoptextcontrol.lockleft">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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="desktoptextcontrol.lockright">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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="desktoptextcontrol.locktop">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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="desktoptextcontrol.mousecursor">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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="desktoptextcontrol.name">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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="desktoptextcontrol.panelindex">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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="desktoptextcontrol.parent">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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 `control</api/user_interface/desktop/desktopuicontrol>`.
>
> 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="desktoptextcontrol.readonly">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.ReadOnly

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

> If `True</api/language/true>`, the text of the control cannot be modified.
>
> This example is in the Opening event of the control.
>
> ``` xojo
> Me.ReadOnly = True
> ```

<div id="desktoptextcontrol.scope">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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="desktoptextcontrol.selectedtext">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.SelectedText

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

> The currently selected text.
>
> This example places the selected text from a `DesktopTextArea</api/user_interface/desktop/desktoptextarea>` into a `DesktopTextField</api/user_interface/desktop/desktoptextfield>`.
>
> ``` xojo
> TextArea1.SelectionStart = 0
> TextArea1.SelectonLength = 10
>
> TextField1.Text = TextArea1.SelectedText
> ```

<div id="desktoptextcontrol.selectionlength">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.SelectionLength

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

> The number of selected characters.
>
> A SelectionLength of 0 means an insertion point rather than a selection. A value greater than the number of characters in the control means that the selection is from `SelectionStart<desktoptextcontrol.selectionstart>` to the end of the control.
>
> On Windows, selecting text via code does not display the text as selected unless the control has the focus. If you want this behavior, call `SetFocus<desktopuicontrol.setfocus>` before setting the selection.
>
> This example selects the first 10 characters of TextArea1.
>
> ``` xojo
> TextArea1.SelectionStart = 0
> TextArea1.SelectionLength = 10
> ```

<div id="desktoptextcontrol.selectionstart">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.SelectionStart

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

> The position of the insertion point.
>
> A value of zero means that the insertion point is before the first character. Use SelectionStart to set the position of the insertion point in the text. Use SelectionStart in conjunction with `SelectionLength<desktoptextcontrol.selectionlength>` to select a portion of the text in the control, beginning with SelectionStart and extending for `SelectionLength<desktoptextcontrol.selectionlength>` characters.
>
> On Windows, selecting text via code does not display the text as selected unless the control has the focus. If you want this behavior, call `SetFocus<desktopuicontrol.setfocus>` before setting the selection.
>
> This example selects the first 10 characters of TextArea1.
>
> ``` xojo
> TextArea1.SelectionStart = 0
> TextArea1.SelectionLength = 10
> ```

<div id="desktoptextcontrol.tabindex">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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="desktoptextcontrol.text">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.Text

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

> The text displayed.
>
> Assigning a `string</api/data_types/string>` to the Text property replaces the entire contents of the control. The font, size, and color are uniform and match the values last set with the FontName, FontSize, and TextColor properties, or if these haven't been used, the settings in the IDE.
>
> Please note that the implementation of the `DesktopTextField</api/user_interface/desktop/desktoptextfield>` and `DesktopTextArea</api/user_interface/desktop/desktoptextarea>` controls is platform dependent. Do not expect that the text you assign is the same as the text you receive from this property. For example on Mac your text is converted to UTF-8 internally. On Windows all text after a null character (which means chr(0) and not "0") is ignored. End of line characters can change to their platform specific counterpart. Special characters with `Asc</api/math/asc>` values below 32 may be ignored or removed.
>
> Clear (remove) any text that is displayed in the TextArea:
>
> ``` xojo
> TextArea1.Text = ""
> ```
>
> This example places the selected text from a `DesktopTextArea</api/user_interface/desktop/desktoptextarea>` into a `DesktopTextField</api/user_interface/desktop/desktoptextfield>`.
>
> ``` xojo
> TextArea1.SelectionStart = 0
> TextArea1.SelectionLength = 10
>
> TextField1.Text = TextArea1.SelectedText
> ```

<div id="desktoptextcontrol.textalignment">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.TextAlignment

**TextAlignment** As `TextAlignments</api/text/textalignments>`

> Sets the paragraph alignment for entire contents of the control.
>
> Use the `TextAlignments</api/text/textalignments>` enumeration to get/set the value of this property.
>
> For the `DesktopTextArea</api/user_interface/desktop/desktoptextarea>` control, use the `SelectionAlignment<desktoptextarea.selectionalignment>` property to set paragraph alignments for individual paragraphs. Currently the Default alignment is the same as Left aligned. Setting the alignment on Linux requires GTK+ 2.4 or greater.
>
> This example is in the Opening event of the control.
>
> ``` xojo
> Me.TextAlignment = TextAlignments.Center
> ```

<div id="desktoptextcontrol.textcolor">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.TextColor

**TextColor** As `ColorGroup</api/graphics/colorgroup>`

> Gets or sets the color of the text. The default value is black.
>
> The following example sets the TextColor.
>
> ``` xojo
> Me.TextColor = Color.Red
> ```

<div id="desktoptextcontrol.tooltip">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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="desktoptextcontrol.top">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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="desktoptextcontrol.transparent">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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="desktoptextcontrol.underline">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.Underline

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

> If `True</api/language/true>`, applies the underline style to the control's text.
>
> This code underlines the control's text or caption property.
>
> ``` xojo
> Me.Underline = True
> ```

<div id="desktoptextcontrol.validationmask">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.ValidationMask

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

> Use the ValidationMask property to filter user input on a character-by-character basis and add formatting characters.
>
> For example, a mask for a Telephone number field can add parentheses, spaces, and dashes as literals, that are used for formatting, and the digit mask symbol '#' to restrict entry to numbers only. It uses the same mask characters as Visual Basic. If the user enters a character that is prohibited by the mask, it causes the ValidationFailed event to occur.
>
> You can use the ValidationMask property in conjunction with the Format property. The ValidationMask filters the entry, while the Format property applies a format to the entry. The formats are the same as for the `Format</api/text/format>` function.
>
> The `DesktopTextField</api/user_interface/desktop/desktoptextfield>` will autocomplete any literal mask characters for the user. If the user uses the Backspace key he/she can backup the autocompletion but only 1 character at a time.
>
> To turn off the ValidationMask, set it to the empty string, "".
>
> You can set the ValidationMask property in the Properties pane. If you use the "#" character as the first character of the mask, there is the remote possibility that it may be confused with the name of a constant. When you use a constant in the Properties pane, you precede its name with the "#" sign. If you want both a constant and a mask to be named "Example", then you should create a new constant named "poundExample" with its value set to "#Example" and assign that in the Properties pane.
>
> The following table shows the characters that you can use to define a mask.
>
> | Mask Character | Description                                                                                                                                                                                                                                                                                    |
> |----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
> | \#             | The single digit placeholder. The user can type only a digit (numeric) character in this position. For example, the mask "(###) \###-####" accepts the entry 5551212121" and returns "(555) 121-2121".                                                                                         |
> | .              | Decimal placeholder.                                                                                                                                                                                                                                                                           |
> | ,              | Thousands separator.                                                                                                                                                                                                                                                                           |
> | :              | Time separator.                                                                                                                                                                                                                                                                                |
> | /              | Date separator.                                                                                                                                                                                                                                                                                |
> | \\             | Mask escape character.                                                                                                                                                                                                                                                                         |
> | &              | Character or space placeholder. It accepts one character.                                                                                                                                                                                                                                      |
> | C              | Character or space placeholder, where entry is optional. It operates like the '&' placeholder. For example, the mask "CCCC-CC" formats "1233ed" as "1233-ed".                                                                                                                                  |
> | \>             | Convert all the characters that follow to uppercase.                                                                                                                                                                                                                                           |
> | \<             | Convert all the characters that follow to lowercase.                                                                                                                                                                                                                                           |
> | A              | Alphanumeric character placeholder, where entry is mandatory.                                                                                                                                                                                                                                  |
> | a              | Alphanumeric character placeholder, where entry is optional.                                                                                                                                                                                                                                   |
> | 0              | The literal "0" (zero). For example, the mask "99.00" formats the entry "22" as "22.00". The mask "CC0-9999" accepts the entry "1234" and returns it as "CC0-1234". The mask "##,###.00" accepts the entry "12345" and returns "12,345.00". The mask "99.00" accepts "21" and returns "21.00". |
> | 9              | A Single (numeric) digit, where entry is optional.                                                                                                                                                                                                                                             |
> | ?              | Alphabetic placeholder. Entry is optional. For example, the mask "???" accepts three alphabetic characters. It rejects numeric characters.                                                                                                                                                     |
> | Any literal    | All other symbols are displayed as literals for formatting purposes. For example, the mask "99\[9\]" accepts the entry "333" and returns "33\[3\]".                                                                                                                                            |
> | ~              | Reserved for future use. If you use "~" it will trigger an exception error. Use ~ instead.                                                                                                                                                                                                     |
>
> | Mask         | Description                                                          |
> |--------------|----------------------------------------------------------------------|
> | 999,999.99   | Formats 11122233 as "111,222.33" (Using the US thousands separator.) |
> | 99.00        | Formats "22" as "22.00."                                             |
> | \###-##-#### | US Social Security number. Fomats "123456789" as 123-45-6789.        |
>
> ``` xojo
> TextField1.ValidationMask = "###-##-####"
> TextField1.ValidationMask = "(###) ###-####" ' US Phone number, with area code
> ```
>
> If the user tries to enter a character that is prohibited by the mask, a ValidationFailed event occurs. The character that the user attempted to enter and the character position is passed to the ValidationFailed event, where you can handle the keystroke as you like.
>
> To cancel the ValidationMask, set it to the empty string:
>
> ``` xojo
> TextField1.ValidationMask = ""
> ```

<div id="desktoptextcontrol.visible">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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="desktoptextcontrol.width">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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="desktoptextcontrol.window">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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="desktoptextcontrol.acceptfiledrop">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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="desktoptextcontrol.acceptpicturedrop">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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="desktoptextcontrol.acceptrawdatadrop">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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="desktoptextcontrol.accepttextdrop">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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="desktoptextcontrol.addtext">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.AddText

**AddText**(text As `String</api/data_types/string>`)

> Adds the passed *text* to the current Text. Call AddText rather than using the `+</api/language/operators/mathematical/+>` operator to add text to existing text.
>
> This example reads a text field in blocks of 1000 characters using Read.
>
> ``` xojo
> Var f As FolderItem
> Var dlg As OpenFileDialog
> Var t As TextInputStream
>
> ' create a new OpenFileDialog
> dlg = New OpenFileDialog
> ' set what type of file it looks for
> dlg.Filter = "text/plain"
>
> ' run the dialog
> f = dlg.ShowModal
>
> ' check to make sure the user didn't click cancel
> If f <> Nil Then
> Try
>     t = TextInputStream.Open(f)
>     ' Read all of the text, 1000 characters at a time
>     ' into the TextField
>     While Not t.EndOfFile
>     myTextArea.AddText(t.Read(1000, Encodings.UTF8))
>     Wend
>     t.Close
> Catch error As IOException
>     ' the file could not be a read as a text file
>     MessageBox("The selected file is not a text file. Error: " + error.Message)
> End If
> Else
> ' the user clicked cancel... just ignore it
> End If
> ```

<div id="desktoptextcontrol.characterposition">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.CharacterPosition

**CharacterPosition**(LineNumber As `Integer</api/data_types/integer>`) As `Integer</api/data_types/integer>`

Returns as an `Integer</api/data_types/integer>` the character position for pixel coordinates *X*, *Y* relative to the control.

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

<div class="rst-class">

forsearch

</div>

DesktopTextControl.CharacterPosition

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

> Returns as an `Integer</api/data_types/integer>` the character position for pixel coordinates *X*, *Y* relative to the control.
>
> Characters are numbered consecutively from the start until the end of the control. The first character is numbered 1. The first line is numbered zero.
>
> This example gets the character position of the first character of the second line.
>
> ``` xojo
> Var i As Integer
> i = TextArea1.CharacterPosition(1)
> ```
>
> This example is in the MouseDown event of the control. The event passes in the X,Y coordinates of the MouseDown event. The example gets the position of the character at the passed coordinates.
>
> ``` xojo
> Var i As Integer
> i = Me.CharacterPosition(x, y)
> MessageBox(i.ToString)
> Return True
> ```

<div id="desktoptextcontrol.close">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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="desktoptextcontrol.copy">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.Copy

**Copy**

> Copies the selected text in the TextArea to the Clipboard, including the styled text information.
>
> This example copies the selected text and places it on the Clipboard.
>
> ``` xojo
> TextArea1.SelectionStart = 0
> TextArea1.SelectionLength = 10
> TextArea1.Copy
> ```

<div id="desktoptextcontrol.drawinto">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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="desktoptextcontrol.insertionposition">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.InsertionPosition

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

> Returns (as an `Integer</api/data_types/integer>`) returns the position of the insertion point closest to pixel coordinates X,Y relative to the control. The returned value is zero-based.
>
> This example is in the MouseDown event of a `DesktopTextArea</api/user_interface/desktop/desktoptextarea>`. This event passes in the X,Y coordinates of the MouseDown event and the method returns the corresponding character position.
>
> ``` xojo
> Var i As Integer
> i = TextArea1.InsertionPosition(x, y)
> MessageBox(i.ToString)
> Return True
> ```

<div id="desktoptextcontrol.linenumber">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.LineNumber

**LineNumber**(CharPosition As `Integer</api/data_types/integer>`) As `Integer</api/data_types/integer>`

> Returns (as an `Integer</api/data_types/integer>`) the line number in which the *CharacterPosition* character appears.
>
> Characters are numbered consecutively with the first character numbered 1. The first line is numbered zero. Used with ScrollPosition, this lets you scroll the control to a particular place in the text.
>
> The line number reflects line breaks from both hard line breaks in the text and soft line breaks caused by word-wrapping within the control.
>
> Gets the line number for the character at position 100:
>
> ``` xojo
> Var lineNum As Integer = TextArea1.LineNumber(100)
> ```
>
> This example searches a TextArea using text provided in a TextField and then scrolls to the text in the TextArea:
>
> ``` xojo
> Var searchText As String = TextField1.Text
> Var position As Integer = TextArea1.Text.IndexOf(searchText)
>
> If position > -1 Then
>   TextArea1.VerticalScrollPosition = TextArea1.LineNumber(position)
> Else
>   ' IndexOf returns -1 if no match was found.
> End If
> ```

<div id="desktoptextcontrol.paste">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.Paste

**Paste**

> Pastes the styled or unstyled text on the Clipboard into the editing area at the insertion point, adding the text to the existing text.
>
> When pasting into a `DesktopTextArea</api/user_interface/desktop/desktoptextarea>`, if the text is styled, the style information is preserved.
>
> This example pastes the contents of the Clipboard into TextArea2 at the insertion point.
>
> ``` xojo
> TextArea2.Paste
> ```

<div id="desktoptextcontrol.refresh">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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="rst-class">

forsearch

</div>

DesktopTextControl.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="desktoptextcontrol.selectall">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.SelectAll

**SelectAll**

> Selects all of the text in the control. If there is no text in the control, SelectAll does nothing.
>
> This example selects all the text in the control.
>
> ``` xojo
> TextArea1.SelectAll
> ```

<div id="desktoptextcontrol.setfocus">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.SetFocus

**SetFocus**

> If applicable, sets the focus to the DesktopUIControl. 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="desktoptextcontrol.closing">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.Closing

**Closing**

> The control is closing.

<div id="desktoptextcontrol.constructcontextualmenu">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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="desktoptextcontrol.contextualmenuitemselected">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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 **DesktopUIControl** 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="desktoptextcontrol.dragenter">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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 DesktopUIControl.
>
> 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="desktoptextcontrol.dragexit">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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 DesktopUIControl.
>
> The *Obj* parameter is the item being dragged. The *Action* parameter specifies the type of drag action.

<div id="desktoptextcontrol.dragover">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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 DesktopUIControl.
>
> The *Obj* parameter is the object being dragged. The coordinates x and y are relative to the **DesktopUIControl**. 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="desktoptextcontrol.dropobject">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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="desktoptextcontrol.focuslost">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.FocusLost

**FocusLost**

> The `control</api/user_interface/desktop/desktopuicontrol>` has lost 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="desktoptextcontrol.focusreceived">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.FocusReceived

**FocusReceived**

> The `control</api/user_interface/desktop/desktopuicontrol>` has received the focus and has a selection rectangle around it.
>
> <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="desktoptextcontrol.keydown">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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.
>
> 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.

<div id="desktoptextcontrol.keyup">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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="desktoptextcontrol.menubarselected">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.MenuBarSelected

**MenuBarSelected**

> Indicates that the control has the focus and a menu (not a menu item) has been selected by the user.

<div id="desktoptextcontrol.mousedown">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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 `control</api/user_interface/desktop/desktopuicontrol>`.
>
> `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="desktoptextcontrol.mousedrag">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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="desktoptextcontrol.mouseenter">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.MouseEnter

**MouseEnter**

> The mouse has entered the area of the control.

<div id="desktoptextcontrol.mouseexit">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.MouseExit

**MouseExit**

> The mouse has left the area of the control.

<div id="desktoptextcontrol.mousemove">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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="desktoptextcontrol.mouseup">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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 `control</api/user_interface/desktop/desktopuicontrol>`. Mouse clicks that are released to the left or above a control are negative.

<div id="desktoptextcontrol.mousewheel">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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="desktoptextcontrol.opening">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.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
> ```

<div id="desktoptextcontrol.selectionchanged">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.SelectionChanged

**SelectionChanged**

> The range of characters highlighted has changed.

<div id="desktoptextcontrol.textchanged">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.TextChanged

**TextChanged**

> The Text property has been changed.

<div id="desktoptextcontrol.validationfailed">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopTextControl.ValidationFailed

**ValidationFailed**(InvalidText As `String</api/data_types/string>`, StartPosition As `Integer</api/data_types/integer>`)

> The user has tried to enter a character that is prohibited by the ValidationMask property.
>
> *InvalidText* is the entire character string up to and including the invalid text. *StartPosition* is the starting character position in which the actual invalid text was entered. The first character is numbered 1. If no code is provided in this event and a validation error occurs, you will hear the default system beep.

## Notes

<span class="title-ref">DesktopTextControl</span> is the base class for both `DesktopTextArea</api/user_interface/desktop/desktoptextarea>` and `DesktopTextField</api/user_interface/desktop/desktoptextfield>`. <span class="title-ref">DesktopTextControl</span> is an abstract class and it is not intended for instantiation. Use `DesktopTextArea</api/user_interface/desktop/desktoptextarea>` for multiline and styled controls and `DesktopTextField</api/user_interface/desktop/desktoptextfield>` for single line text fields.

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

### Execution order of menuhandlers

The intrinsic control menu handlers (such as `DesktopTextField</api/user_interface/desktop/desktoptextfield>`.SelectAll) are handled after any user-defined menu handlers on the TextField subclass (if it was subclassed). This means that if you have a SelectAll handler on the Window of the `DesktopTextField</api/user_interface/desktop/desktoptextfield>`, it will no longer be called when the `DesktopTextField</api/user_interface/desktop/desktoptextfield>` has focus, because the `DesktopTextField</api/user_interface/desktop/desktoptextfield>` will now handle it first. In this situation, create a `DesktopTextField</api/user_interface/desktop/desktoptextfield>` subclass that defines its own SelectAll handler, and handle the desired behavior there.

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

### Masks

Use the `ValidationMask<desktoptextcontrol.validationmask>` property to filter user input on a character-by-character basis and add formatting characters. For example, a mask for a Telephone number field can add parentheses, spaces, and dashes as literals, that are used for formatting, and the digit mask symbol '#' to restrict entry to numbers only. See `ValidationMask<desktoptextcontrol.validationmask>` for details.

## Compatibility

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

<div class="seealso">

`DesktopUIControl</api/user_interface/desktop/desktopuicontrol>` parent class; `DesktopUIControl</api/user_interface/desktop/desktopuicontrol>`, `DesktopTextArea</api/user_interface/desktop/desktoptextarea>`, `DesktopTextField</api/user_interface/desktop/desktoptextfield>` classes.

</div>
