<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSEvent/mouseEvent(with:location:modifierFlags:timestamp:windowNumber:context:eventNumber:clickCount:pressure:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSEvent(cm)mouseEventWithType:location:modifierFlags:timestamp:windowNumber:context:eventNumber:clickCount:pressure:"
  },
  "title" : "mouseEvent(with:location:modifierFlags:timestamp:windowNumber:context:eventNumber:clickCount:pressure:)"
}
-->

# mouseEvent(with:location:modifierFlags:timestamp:windowNumber:context:eventNumber:clickCount:pressure:)

Creates and returns a new event object that describes a mouse-down, -up, -moved, or -dragged event.

```
class func mouseEvent(with type: NSEvent.EventType, location: NSPoint, modifierFlags flags: NSEvent.ModifierFlags, timestamp time: TimeInterval, windowNumber wNum: Int, context unusedPassNil: NSGraphicsContext?, eventNumber eNum: Int, clickCount cNum: Int, pressure: Float) -> NSEvent?
```

## Parameters

`type`

One of the modifier key masks described in [`NSEvent.EventType`](/documentation/AppKit/NSEvent/EventType), or an `NSInternalInconsistencyException` is raised.

`location`

The cursor location in the base coordinate system of the window specified by `windowNum`.

`flags`

An integer bit field containing any of the modifier key masks described in `Getting Unicode Values`, combined using the C bitwise OR operator.

`time`

The time the event occurred in seconds since system startup.

`wNum`

An integer that identifies the window device associated with the event, which is associated with the `NSWindow` that will receive the event.

`unusedPassNil`

The display graphics context of the event. Pass `nil` for this parameter.

`eNum`

An identifier for the new event. It’s normally taken from a counter for mouse events, which continually increases as the application runs.

`cNum`

The number of mouse clicks associated with the mouse event.

`pressure`

A value from `0.0` to `1.0` indicating the pressure applied to the input device on a mouse event, used for an appropriate device such as a graphics tablet. For devices that aren’t pressure-sensitive, the value should be either `0.0` or `1.0`.

## Return Value

The created `NSEvent` instance or `nil` if the instance could not be created.

## See Also

[`clickCount`](/documentation/AppKit/NSEvent/clickCount)

The number of mouse clicks associated with a mouse-down or mouse-up event.

[`eventNumber`](/documentation/AppKit/NSEvent/eventNumber)

The counter value of the latest mouse or tracking-rectangle event object.

  <doc://com.apple.documentation/documentation/Foundation/ProcessInfo/systemUptime>

[`pressure`](/documentation/AppKit/NSEvent/pressure)

A normalized value that indicates the degree of pressure applied to an appropriate input device.



---

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)