<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextView/selectionRange(forProposedRange:granularity:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTextView(im)selectionRangeForProposedRange:granularity:"
  },
  "title" : "selectionRange(forProposedRange:granularity:)"
}
-->

# selectionRange(forProposedRange:granularity:)

Returns an adjusted selected range based on the selection granularity.

```
func selectionRange(forProposedRange proposedCharRange: NSRange, granularity: NSSelectionGranularity) -> NSRange
```

## Parameters

`proposedCharRange`

The proposed selected range.

`granularity`

The selection granularity.

## Return Value

The adjusted selected range, taking into account the selection granularity.

## Discussion

This method is invoked repeatedly during mouse tracking to modify the range of the selection. Override this method to specialize selection behavior.

## See Also

[`selectionGranularity`](/documentation/AppKit/NSTextView/selectionGranularity)

The selection granularity for subsequent extension of a selection.



---

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)