<!--
{
  "availability" : [
    "macOS: 10.0.0 - 10.13.0"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSDrawerDelegate/drawerShouldClose(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSDrawerDelegate(im)drawerShouldClose:"
  },
  "title" : "drawerShouldClose(_:)"
}
-->

# drawerShouldClose(_:)

Asks the delegate if the specified drawer should close.

```
optional func drawerShouldClose(_ sender: NSDrawer) -> Bool
```

## Parameters

`sender`

The drawer being closed.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> to allow the drawer to close; <doc://com.apple.documentation/documentation/Swift/false> to prevent it from closing.

## Discussion

This method is invoked on user-initiated attempts to close a drawer by dragging it or when the [`NSDrawerDelegate`](/documentation/AppKit/NSDrawerDelegate) method is called.

---

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)