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

# wantsToTrackMouse(for:in:of:atCharacterIndex:)

Allows an attachment to specify the events for which it tracks the mouse.

```
@MainActor func wantsToTrackMouse(for theEvent: NSEvent, in cellFrame: NSRect, of controlView: NSView?, atCharacterIndex charIndex: Int) -> Bool
```

## Discussion

`theEvent` is the event in question that occurred in `cellFrame` inside `controlView`. `charIndex` is the index of the attachment character within the text. If [`wantsToTrackMouse()`](/documentation/AppKit/NSTextAttachmentCellProtocol/wantsToTrackMouse()) returns <doc://com.apple.documentation/documentation/Swift/true>, this method allows the attachment to decide whether it wishes to do so for particular events.

---

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)