<!--
{
  "availability" : [
    "macCatalyst: 13.1.0 -",
    "macOS: 10.4.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreGraphics",
  "identifier" : "/documentation/CoreGraphics/CGEvent/init(mouseEventSource:mouseType:mouseCursorPosition:mouseButton:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Core Graphics",
      "CoreGraphics"
    ],
    "preciseIdentifier" : "c:@F@CGEventCreateMouseEvent"
  },
  "title" : "init(mouseEventSource:mouseType:mouseCursorPosition:mouseButton:)"
}
-->

# init(mouseEventSource:mouseType:mouseCursorPosition:mouseButton:)

Returns a new Quartz mouse event.

```
init?(mouseEventSource source: CGEventSource?, mouseType: CGEventType, mouseCursorPosition: CGPoint, mouseButton: CGMouseButton)
```

## Parameters

`source`

An event source taken from another event, or `NULL`.

`mouseType`

A mouse event type. Pass one of the constants listed in [`CGEventType`](/documentation/CoreGraphics/CGEventType).

`mouseCursorPosition`

The position of the mouse cursor in global coordinates.

`mouseButton`

The button that’s changing state. Pass one of the constants listed in [`CGMouseButton`](/documentation/CoreGraphics/CGMouseButton). This parameter is ignored unless the `mouseType` parameter is `kCGEventOtherMouseDown`, `kCGEventOtherMouseDragged`, or `kCGEventOtherMouseUp`.

## Return Value

A new mouse event, or `NULL` if the event could not be created. When you no longer need the event, you should release it using the function `CFRelease`.

## Discussion

---

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)