<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSCell/stopTracking(last:current:in:mouseIsUp:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSCell(im)stopTracking:at:inView:mouseIsUp:"
  },
  "title" : "stopTracking(last:current:in:mouseIsUp:)"
}
-->

# stopTracking(last:current:in:mouseIsUp:)

Stops tracking mouse events within the receiver.

```
func stopTracking(last lastPoint: NSPoint, current stopPoint: NSPoint, in controlView: NSView, mouseIsUp flag: Bool)
```

## Parameters

`lastPoint`

Contains the previous position of the cursor.

`stopPoint`

The current location of the cursor.

`controlView`

The `NSControl` object managing the receiver.

`flag`

If <doc://com.apple.documentation/documentation/Swift/true>, this method was invoked because the user released the mouse button; otherwise, if <doc://com.apple.documentation/documentation/Swift/false>, the cursor left the designated tracking rectangle.

## Discussion

The default `NSCell` implementation of [`trackMouse(with:in:of:untilMouseUp:)`](/documentation/AppKit/NSCell/trackMouse(with:in:of:untilMouseUp:)) invokes this method when the cursor has left the bounds of the receiver or the mouse button goes up. The default `NSCell` implementation of this method does nothing. Subclasses often override this method to provide customized tracking behavior. The following example increments the state of a tristate cell when the mouse button is clicked:

```objc
- (void)stopTracking:(NSPoint)lastPoint at:(NSPoint)stopPoint
    inView:(NSView *)controlView mouseIsUp:(BOOL)flag
{
    if (flag == YES) {
        [self setTriState:([self triState]+1)];
    }
}
```

---

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)