I have an NSTextView with images in it. I want to add tracking areas for those images. I need the frame of the cells holding the images in order to create tracking areas.
So my question: how can I get the frame for the NSTextAttachments in the coordinate system of the NSTextView?
I am programmatically changing the size of an image in the text view and this is when I need to create this new tracking area. I am doing the following to create an attributed string with the text attachment, and then programmatically inserting this into my text view's attributed string. But once I do all this I do not know how to create my tracking area for the new attachment.
-(NSAttributedString*)attributedStringAttachmentForImageObject:(id)object {
NSFileWrapper* fileWrapper = [[NSFileWrapper alloc] initRegularFileWithContents:[object TIFFRepresentationUsingCompression:NSTIFFCompressionLZW factor:1.0]];
[fileWrapper setPreferredFilename:@"image.tiff"];
NSTextAttachment* attachment = [[NSTextAttachment alloc] initWithFileWrapper:fileWrapper];
NSAttributedString* aString = [NSAttributedString attributedStringWithAttachment:attachment];
[fileWrapper release];
[attachment release];
return aString;
}