<!--
{
  "availability" : [
    "macOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextSelectionManager/Delegate-swift.protocol",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSTextSelectionManagerDelegate"
  },
  "title" : "NSTextSelectionManager.Delegate"
}
-->

# NSTextSelectionManager.Delegate

A set of methods that manage text selection state and let you customize selection behavior.

```
protocol Delegate : NSObjectProtocol
```

## Overview

Delegates are responsible for managing the text selection state and can customize selection behavior by implementing optional methods.

## Topics

### Instance Properties

[`var textSelection: NSTextSelection?`](/documentation/AppKit/NSTextSelectionManager/Delegate-swift.protocol/textSelection)

The current text selection.

### Instance Methods

[`func selectionManager(NSTextSelectionManager, frameOfTextContainerAt: NSPoint) -> NSRect`](/documentation/AppKit/NSTextSelectionManager/Delegate-swift.protocol/selectionManager(_:frameOfTextContainerAt:))

Returns the frame of the text container at the specified point.

[`func selectionManager(NSTextSelectionManager, locationOfTextContainerAt: NSPoint) -> (any NSTextLocation)?`](/documentation/AppKit/NSTextSelectionManager/Delegate-swift.protocol/selectionManager(_:locationOfTextContainerAt:))

Returns the text location of the text container at the specified point.

[`func selectionManager(NSTextSelectionManager, makeDraggingSession: NSGestureRecognizer) -> NSDraggingSession?`](/documentation/AppKit/NSTextSelectionManager/Delegate-swift.protocol/selectionManager(_:makeDraggingSession:))

Creates and returns a dragging session for the specified gesture recognizer.

[`func selectionManager(NSTextSelectionManager, shouldBeginSelectionAt: NSPoint) -> Bool`](/documentation/AppKit/NSTextSelectionManager/Delegate-swift.protocol/selectionManager(_:shouldBeginSelectionAt:))

Asks the delegate whether a selection can begin at the specified point.

[`func selectionManagerDidEndSelection(NSTextSelectionManager)`](/documentation/AppKit/NSTextSelectionManager/Delegate-swift.protocol/selectionManagerDidEndSelection(_:))

Tells the delegate that a selection gesture has ended.

[`func selectionManagerWillBeginSelection(NSTextSelectionManager)`](/documentation/AppKit/NSTextSelectionManager/Delegate-swift.protocol/selectionManagerWillBeginSelection(_:))

Tells the delegate that a selection gesture is about to begin.

## Relationships

### Inherits From

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

---

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)