---
title: "wantsToTrackMouse(for:in:of:atCharacterIndex:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nstextattachmentcellprotocol/wantstotrackmouse(for:in:of:atcharacterindex:)"
---

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

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

## Declaration

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

## Discussion

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() returns true, this method allows the attachment to decide whether it wishes to do so for particular events.

## See Also

### Responding to mouse events

- [wantsToTrackMouse()](appkit/nstextattachmentcellprotocol/wantstotrackmouse().md)
- [trackMouse(with:in:of:untilMouseUp:)](appkit/nstextattachmentcellprotocol/trackmouse(with:in:of:untilmouseup:).md)
- [trackMouse(with:in:of:atCharacterIndex:untilMouseUp:)](appkit/nstextattachmentcellprotocol/trackmouse(with:in:of:atcharacterindex:untilmouseup:).md)
