---
title: "enterExitEvent(with:location:modifierFlags:timestamp:windowNumber:context:eventNumber:trackingNumber:userData:)"
framework: appkit
role: symbol
role_heading: Type Method
path: "appkit/nsevent/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.

## Declaration

```swift
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 doc://com.apple.appkit/documentation/AppKit/NSView/addTrackingRect(_:owner:userData:assumeInside:).
- `data`: Data arbitrarily associated with the tracking rectangle when it was set up using the NSView method doc://com.apple.appkit/documentation/AppKit/NSView/addTrackingRect(_:owner:userData:assumeInside:).

## Return Value

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

## See Also

### Related Documentation

- [eventNumber](appkit/nsevent/eventnumber.md)
- [trackingNumber](appkit/nsevent/trackingnumber.md)
- [systemUptime](foundation/processinfo/systemuptime.md)
- [userData](appkit/nsevent/userdata.md)

### Creating an event object

- [keyEvent(with:location:modifierFlags:timestamp:windowNumber:context:characters:charactersIgnoringModifiers:isARepeat:keyCode:)](appkit/nsevent/keyevent(with:location:modifierflags:timestamp:windownumber:context:characters:charactersignoringmodifiers:isarepeat:keycode:).md)
- [mouseEvent(with:location:modifierFlags:timestamp:windowNumber:context:eventNumber:clickCount:pressure:)](appkit/nsevent/mouseevent(with:location:modifierflags:timestamp:windownumber:context:eventnumber:clickcount:pressure:).md)
- [otherEvent(with:location:modifierFlags:timestamp:windowNumber:context:subtype:data1:data2:)](appkit/nsevent/otherevent(with:location:modifierflags:timestamp:windownumber:context:subtype:data1:data2:).md)
- [init(eventRef:)](appkit/nsevent/init(eventref:).md)
- [init(cgEvent:)](appkit/nsevent/init(cgevent:)-4igjn.md)
