---
title: "menu(for:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsview/menu(for:)"
---

# menu(for:)

Overridden by subclasses to return a context-sensitive pop-up menu for a given mouse-down event.

## Declaration

```swift
func menu(for event: NSEvent) -> NSMenu?
```

## Parameters

- `event`: An object representing a mouse-down event.

## Mentioned in

Supporting Writing Tools via the pasteboard

## Discussion

Discussion The view can use information in the mouse event, such as its location over a particular element of the view, to determine what kind of menu to return. For example, a text object might display a text-editing menu when the cursor lies over text and a menu for changing graphics attributes when the cursor lies over an embedded image. The default implementation returns the view’s normal menu.

## See Also

### Related Documentation

- [menu](appkit/nsresponder/menu.md)

### Managing Contextual Menus

- [defaultMenu](appkit/nsview/defaultmenu.md)
- [willOpenMenu(_:with:)](appkit/nsview/willopenmenu(_:with:).md)
- [didCloseMenu(_:with:)](appkit/nsview/didclosemenu(_:with:).md)
