<!--
{
  "availability" : [
    "macOS: 10.11.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSAlignmentFeedbackFilter/alignmentFeedbackTokenForHorizontalMovement(in:previousX:alignedX:defaultX:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSAlignmentFeedbackFilter(im)alignmentFeedbackTokenForHorizontalMovementInView:previousX:alignedX:defaultX:"
  },
  "title" : "alignmentFeedbackTokenForHorizontalMovement(in:previousX:alignedX:defaultX:)"
}
-->

# alignmentFeedbackTokenForHorizontalMovement(in:previousX:alignedX:defaultX:)

Requests a feedback token for the alignment of an object requiring horizontal movement only.

```
func alignmentFeedbackTokenForHorizontalMovement(in view: NSView?, previousX: CGFloat, alignedX: CGFloat, defaultX: CGFloat) -> (any NSAlignmentFeedbackToken)?
```

## Parameters

`view`

The view ([`NSView`](/documentation/AppKit/NSView)) in which the object was moved.

`previousX`

The horizontal location (<doc://com.apple.documentation/documentation/CoreFoundation/CGFloat-swift.struct>) of the object prior to its move.

`alignedX`

The new horizontal location (<doc://com.apple.documentation/documentation/CoreFoundation/CGFloat-swift.struct>) of the object if alignment occurs.

`defaultX`

The current horizontal location (<doc://com.apple.documentation/documentation/CoreFoundation/CGFloat-swift.struct>) of the object. This is where the user actually moved the object. This location may be offset from the location of the cursor.

## Return Value

If the system determines that the alignment should not occur, a null value is returned. Otherwise, a feedback token of type `NSAlignmentFeedbackToken` is returned.

## Discussion

This method requests a feedback token for the alignment of an object requiring horizontal movement only.

If a feedback token is returned, call [`performFeedback(_:performanceTime:)`](/documentation/AppKit/NSAlignmentFeedbackFilter/performFeedback(_:performanceTime:)) to initiate haptic feedback. Then, move the object to its aligned location.

If no feedback token is returned, don’t perform the horizontal alignment or request haptic feedback. Even if this horizontal alignment fails, be sure to check other alignments. For example, a vertical alignment may still be allowed. If no alignments will occur, move the object to its default location.

## See Also

[`-  performFeedback:performanceTime:`](/documentation/AppKit/NSAlignmentFeedbackFilter/performFeedback(_:performanceTime:))

Performs the haptic feedback described by one or more alignment feedback tokens.



---

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)