<!--
{
  "availability" : [
    "macCatalyst: 13.1.0 -",
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreGraphics",
  "identifier" : "/documentation/CoreGraphics/CGAssociateMouseAndMouseCursorPosition(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Graphics"
    ],
    "preciseIdentifier" : "c:@F@CGAssociateMouseAndMouseCursorPosition"
  },
  "title" : "CGAssociateMouseAndMouseCursorPosition(_:)"
}
-->

# CGAssociateMouseAndMouseCursorPosition(_:)

Connects or disconnects the mouse and cursor while an application is in the foreground.

```
func CGAssociateMouseAndMouseCursorPosition(_ connected: boolean_t) -> CGError
```

## Parameters

`connected`

Pass <doc://com.apple.documentation/documentation/Swift/true> to connect the mouse and cursor; otherwise, pass <doc://com.apple.documentation/documentation/Swift/false>.

## Return Value

A result code. To interpret the result code, see [`CGError`](/documentation/CoreGraphics/CGError).

## Discussion

Call this function to disconnect the mouse from the cursor. When you call this function, the events your application receives from the system have a constant absolute location but contain delta updates to the X and Y coordinates of the mouse. You can hide the cursor or change it into something appropriate for your application. You can reposition the cursor by using the function [`CGDisplayMoveCursorToPoint(_:_:)`](/documentation/CoreGraphics/CGDisplayMoveCursorToPoint(_:_:)) or the function [`CGWarpMouseCursorPosition(_:)`](/documentation/CoreGraphics/CGWarpMouseCursorPosition(_:)).

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)