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

# enterExitEvent(with:location:modifierFlags:timestamp:windowNumber:context:eventNumber:trackingNumber:userData:)

Creates and returns a new event object that describes a tracking-rectangle or cursor-update event.

```
class func enterExitEvent(with type: NSEvent.EventType, location: NSPoint, modifierFlags flags: NSEvent.ModifierFlags, timestamp time: TimeInterval, windowNumber wNum: Int, context unusedPassNil: NSGraphicsContext?, eventNumber eNum: Int, trackingNumber tNum: Int, userData data: UnsafeMutableRawPointer?) -> NSEvent?
```

## Parameters

`type`

One of the following event-type constants:  `NSMouseEntered`, `NSMouseExited`, `NSCursorUpdate`. If the specified constant is not one of these, 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.

`tNum`

A number that identifies the tracking rectangle. This identifier is the same as that returned by the `NSView` method [`addTrackingRect(_:owner:userData:assumeInside:)`](/documentation/AppKit/NSView/addTrackingRect(_:owner:userData:assumeInside:)).

`data`

Data arbitrarily associated with the tracking rectangle when it was set up using the `NSView` method [`addTrackingRect(_:owner:userData:assumeInside:)`](/documentation/AppKit/NSView/addTrackingRect(_:owner:userData:assumeInside:)).

## Return Value

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

## See Also

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

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

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

The identifier of a mouse-tracking event.

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

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

The data associated with a mouse-tracking event.



---

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)