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

# rulerView(_:willMove:toLocation:)

Returns a potentially modified location to which the marker should be moved.

```
func rulerView(_ ruler: NSRulerView, willMove marker: NSRulerMarker, toLocation location: CGFloat) -> CGFloat
```

## Parameters

`ruler`

The ruler view sending the message.

`marker`

The marker to be moved.

`location`

The new location for the marker, in the ruler view’s coordinates.

## Return Value

The modified location to which the marker should be moved.

## Discussion

This method ensures that the proposed `location` of `aMarker` lies within the appropriate bounds for the receiver’s text container. Appropriate bounds are those of the text container minus its line fragment padding.

Typically, the ruler view’s width matches that of its text view.

---

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)