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

# autoscroll(with:)

Scrolls the view’s closest ancestor [`NSClipView`](/documentation/AppKit/NSClipView) object proportionally to the distance of an event that occurs outside of it.

```
func autoscroll(with event: NSEvent) -> Bool
```

## Parameters

`event`

An event object whose location should be expressed in the window’s base coordinate system (which it normally is), not the receiving view’s.

## Return Value

Returns <doc://com.apple.documentation/documentation/Swift/true> if any scrolling is performed; otherwise returns <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

View objects that track mouse-dragged events can use this method to scroll automatically when the cursor is dragged outside of the [`NSClipView`](/documentation/AppKit/NSClipView) object. Repeated invocations of this method (with an appropriate delay) result in continual scrolling, even when the mouse doesn’t move.

## See Also

[`func isDescendant(of: NSView) -> Bool`](/documentation/AppKit/NSView/isDescendant(of:))

Returns a Boolean value that indicates whether the view is a subview of the specified view.

[`func autoscroll(with: NSEvent) -> Bool`](/documentation/AppKit/NSClipView/autoscroll(with:))

Scrolls the clip view proportionally to `theEvent`’s distance outside of it.



---

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)