---
title: "selectionRange(forProposedRange:granularity:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nstextview/selectionrange(forproposedrange:granularity:)"
---

# selectionRange(forProposedRange:granularity:)

Returns an adjusted selected range based on the selection granularity.

## Declaration

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

## Parameters

- `proposedCharRange`: The proposed selected range.
- `granularity`: The selection granularity.

## Return Value

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

## Discussion

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

### Related Documentation

- [selectionGranularity](appkit/nstextview/selectiongranularity.md)

### Customizing subclass behaviors

- [updateFontPanel()](appkit/nstextview/updatefontpanel().md)
- [updateRuler()](appkit/nstextview/updateruler().md)
- [acceptableDragTypes](appkit/nstextview/acceptabledragtypes.md)
- [updateDragTypeRegistration()](appkit/nstextview/updatedragtyperegistration().md)
- [rangeForUserCharacterAttributeChange](appkit/nstextview/rangeforusercharacterattributechange.md)
- [rangesForUserCharacterAttributeChange](appkit/nstextview/rangesforusercharacterattributechange.md)
- [rangeForUserParagraphAttributeChange](appkit/nstextview/rangeforuserparagraphattributechange.md)
- [rangesForUserParagraphAttributeChange](appkit/nstextview/rangesforuserparagraphattributechange.md)
- [rangeForUserTextChange](appkit/nstextview/rangeforusertextchange.md)
- [rangesForUserTextChange](appkit/nstextview/rangesforusertextchange.md)
- [shouldChangeText(in:replacementString:)](appkit/nstextview/shouldchangetext(in:replacementstring:).md)
- [shouldChangeText(inRanges:replacementStrings:)](appkit/nstextview/shouldchangetext(inranges:replacementstrings:).md)
- [didChangeText()](appkit/nstextview/didchangetext().md)
- [smartInsertDeleteEnabled](appkit/nstextview/smartinsertdeleteenabled.md)
- [smartDeleteRange(forProposedRange:)](appkit/nstextview/smartdeleterange(forproposedrange:).md)
