Method

# ClearFocus

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

## Description

Removes the focus from the control that has the focus, leaving no control with the focus. On Windows only, the app also no longer receives KeyDown events.

## Usage

``` xojo
ClearFocus
```

## Notes

After calling this method on Windows, the app no longer receives Keydown events. Use `DesktopWindow.SetFocus<desktopwindow.setfocus>` if your app needs to continue to receive KeyDown events.

You can set the focus to a specific control using the SetFocus method of the `DesktopUIControl</api/user_interface/desktop/desktopuicontrol>` class.

## Sample code

The following code in the Pressed event of a `DesktopButton</api/user_interface/desktop/desktopbutton>` removes the focus from the object in the window that has the focus, leaving no control with the focus until the user selects or clicks in a control that can get the focus.

``` xojo
ClearFocus
```

## Compatibility

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

<div class="seealso">

`DesktopUIControl</api/user_interface/desktop/desktopuicontrol>`, `DesktopWindow</api/user_interface/desktop/desktopwindow>` classes, `DesktopWindow.SetFocus<desktopwindow.setfocus>` method

</div>
