<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSMenu/popUpContextMenu(_:with:for:with:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSMenu(cm)popUpContextMenu:withEvent:forView:withFont:"
  },
  "title" : "popUpContextMenu(_:with:for:with:)"
}
-->

# popUpContextMenu(_:with:for:with:)

Displays a contextual menu over a view for an event using a specified font.

```
class func popUpContextMenu(_ menu: NSMenu, with event: NSEvent, for view: NSView, with font: NSFont?)
```

## Parameters

`menu`

The menu object to use for the contextual menu.

`event`

An [`NSEvent`](/documentation/AppKit/NSEvent) object representing the event.

`view`

The view object over which to display the contextual menu.

`font`

An [`NSFont`](/documentation/AppKit/NSFont) object representing the font for the contextual menu. If you pass in `nil` for the font, the method uses the default font for `menu`.

## Discussion

Specifying a font using the font parameter is discouraged. Instead, set the menu’s font using the [`font`](/documentation/AppKit/NSMenu/font) property, then pass `nil` for the `font` parameter.

---

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)