<!--
{
  "availability" : [
    "macOS: 10.11.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSView/didCloseMenu(_:with:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSView(im)didCloseMenu:withEvent:"
  },
  "title" : "didCloseMenu(_:with:)"
}
-->

# didCloseMenu(_:with:)

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

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

This method is called only if the contextual menu had been opened and the view has previously received the [`willOpenMenu(_:with:)`](/documentation/AppKit/NSView/willOpenMenu(_:with:)) method. When the view receives [`didCloseMenu(_:with:)`](/documentation/AppKit/NSView/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.

---

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)