---
title: "didCloseMenu(_:with:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsview/didclosemenu(_:with:)"
---

# didCloseMenu(_:with:)

Called after a contextual menu that was displayed from the receiving view has been closed.

## Declaration

```swift
func didCloseMenu(_ menu: NSMenu, with event: NSEvent?)
```

## Parameters

- `menu`: The menu that was closed.
- `event`: The event that caused the menu to close, if there was one. If an event did not cause the menu to close, this value is nil.

## Discussion

Discussion This method is called only if the contextual menu had been opened and the view has previously received the willOpenMenu(_:with:) method. When the view receives didCloseMenu(_:with:), it should reset its visual state, if necessary. For example, if a table view selected a row in response to a contextual menu being displayed, this method could deselect the row.

## See Also

### Managing Contextual Menus

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