• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Replacing the standard NSTextAttachmentCell in an NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Replacing the standard NSTextAttachmentCell in an NSTextView


  • Subject: Replacing the standard NSTextAttachmentCell in an NSTextView
  • From: email@hidden
  • Date: Tue, 6 Nov 2007 23:34:23 +0900

Hello,

I'm currently researching how to provide a custom NSCell to replace the current NSTextAttachentCell in an NSTextView.
The reason is that I want to have a different type of attachment not just for images or file objects, but for actual objects in my application.
IOW, something similar to NSTokens (actually I'm using an NSTokenFieldCell subclass) that can represent actual "objects" in a text field...


So, I have insertion working, and the cell fulfills the basic protocol for NSTextAttachment.
The problem is, when cutting and pasting my object back into the text field, it reverts to a standard NSTextAttachmentCell....
How can I override this to insert my special cell?
The problem I am running into is that the NSTextAttachment requires an NSFileWrapper, but since I am not representing a file object, I tested it out using:
NSTextAttachment *textAttachment = [[NSTextAttachment alloc] initWithFileWrapper:nil];
In the above case, paste then doesn't even work....


Also, when reading the .h for NSTextAttachment, its states for the NSTextAttachmentCell:

/* Simple class to provide basic attachment cell functionality. By default this class causes NSTextView to send out delegate messages when the attachment is clicked on or dragged.
*/


How can I get this functionality in my custom cell?
I'm assuming that through this method:

- (BOOL)trackMouse:(NSEvent *)theEvent inRect:(NSRect)cellFrame ofView: (NSView *)controlView atCharacterIndex:(NSUInteger)charIndex untilMouseUp:(BOOL)flag;

How can I get the aforementioned double-click functionality in my custom cell? I know its not "legal" to do something like [[(NSTextView *)controlView delegate] SOME_DELEGATE_METHOD] so I'm curious what is the best way to go about doing this.... I would like the delegate to have a chance to do something as well when double clicked or edited....

Especially the case of pasted text containing values originally representing my special cell, I would like the pasted text to use that special cell, currently I can't get that working...

Thanks for any pointers.

Andre


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Replacing the standard NSTextAttachmentCell in an NSTextView
      • From: Douglas Davidson <email@hidden>
  • Prev by Date: Re: [Q] API/Class for CoverFlow?
  • Next by Date: Re: Extend QuickLook to other standard files
  • Previous by thread: Re: iChat Theater help...
  • Next by thread: Re: Replacing the standard NSTextAttachmentCell in an NSTextView
  • Index(es):
    • Date
    • Thread