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

# wantsToTrackMouse()

Returns a Boolean value that indicates whether the attachment handles mouse events occurring over its image.

```
@MainActor func wantsToTrackMouse() -> Bool
```

## Discussion

The default implementation of this method returns <doc://com.apple.documentation/documentation/Swift/true>. The [`NSView`](/documentation/AppKit/NSView) containing the cell should invoke this method before sending a [`trackMouse(with:in:of:untilMouseUp:)`](/documentation/AppKit/NSTextAttachmentCellProtocol/trackMouse(with:in:of:untilMouseUp:)) message.

For an attachment in an attributed string, if the attachment cell returns <doc://com.apple.documentation/documentation/Swift/false>, its attachment character should be selected rather than the cell being asked to track the mouse. This results in the attachment icon behaving as any regular glyph in text.

---

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)