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

# otherEvent(with:location:modifierFlags:timestamp:windowNumber:context:subtype:data1:data2:)

Creates and returns a new event object that describes a custom event.

```
class func otherEvent(with type: NSEvent.EventType, location: NSPoint, modifierFlags flags: NSEvent.ModifierFlags, timestamp time: TimeInterval, windowNumber wNum: Int, context unusedPassNil: NSGraphicsContext?, subtype: Int16, data1 d1: Int, data2 d2: Int) -> NSEvent?
```

## Parameters

`type`

One of the following event-type constants:

- `NSAppKitDefined`
- `NSSystemDefined`
- `NSApplicationDefined`
- `NSPeriodic`

    If     `type`     is anything else, an     `NSInternalInconsistencyException`     is raised. Your code should only create events of type     `NSApplicationDefined`    .

`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.

`subtype`

A numeric identifier that further differentiates custom events of types `NSAppKitDefined`, `NSSystemDefined`, and `NSApplicationDefined`. `NSPeriodic` events don’t use this attribute.

`d1`

Additional data associated with the event. `NSPeriodic` events don’t use these attributes.

`d2`

Additional data associated with the event. `NSPeriodic` events don’t use these attributes.

## Return Value

The created `NSEvent` object or `nil` if the object couldn’t be created.

## See Also

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

The event’s subtype.

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

Additional data associated with this event.

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

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

Additional data associated with this 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)