# Sandbox.UI.Panel.SetMouseCapture

```csharp
void SetMouseCapture(bool b)
```

Captures the mouse cursor while active. The cursor will be hidden and will be stuck in place.
You will want to use [Sandbox.Mouse.Delta](/api/Sandbox.Mouse/Delta) in
[Sandbox.UI.Panel.Tick](/api/Sandbox.UI.Panel/Tick) while [Sandbox.UI.Panel.HasMouseCapture](/api/Sandbox.UI.Panel/HasMouseCapture) to read mouse movements.

You can call this from [Sandbox.UI.Panel.OnButtonEvent](/api/Sandbox.UI.Panel/OnButtonEvent) for mouse clicks.

### Parameters

- `b` (`bool`): Whether to enable or disable the capture.

Declared in [Sandbox.UI.Panel](/api/Sandbox.UI.Panel).
Assembly: `Sandbox.Engine`.
