<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSView/addCursorRect(_:cursor:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSView(im)addCursorRect:cursor:"
  },
  "title" : "addCursorRect(_:cursor:)"
}
-->

# addCursorRect(_:cursor:)

Establishes  the cursor to be used when the mouse pointer lies within a specified region.

```
func addCursorRect(_ rect: NSRect, cursor object: NSCursor)
```

## Parameters

`rect`

A rectangle defining a region of the view.

`object`

An object representing a cursor.

## Discussion

Cursor rectangles aren’t subject to clipping by superviews, nor are they intended for use with rotated views. You should explicitly confine a cursor rectangle to the view’s visible rectangle to prevent improper behavior.

This method is intended to be invoked only by the [`resetCursorRects()`](/documentation/AppKit/NSView/resetCursorRects()) method. If invoked in any other way, the resulting cursor rectangle will be discarded the next time the view’s cursor rectangles are rebuilt.

## See Also

[`visibleRect`](/documentation/AppKit/NSView/visibleRect)

The portion of the view that isn’t clipped by its superviews.



---

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)