<!--
{
  "availability" : [
    "macOS: 10.6.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSMenuDelegate/confinementRect(for:on:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSMenuDelegate(im)confinementRectForMenu:onScreen:"
  },
  "title" : "confinementRect(for:on:)"
}
-->

# confinementRect(for:on:)

Invoked to allow the delegate to specify a display location for the menu.

```
@MainActor optional func confinementRect(for menu: NSMenu, on screen: NSScreen?) -> NSRect
```

## Parameters

`menu`

The menu object.

`screen`

The screen the menu will open on.

## Return Value

The rectangle the menu should be displayed within, in screen coordinates.

## Discussion

This method is sent to the delegate when a menu is about to be opened on the specified screen.

If you return `NSZeroRect`, or if the delegate doesn’t implement this method, the menu will be confined to the bounds appropriate for the given screen. The returned rect may not be honored in all cases, for example, if it would force the menu to be too small.

---

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)