• 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
Re: NSTextAttachmentCell as rollover in NSTextView?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTextAttachmentCell as rollover in NSTextView?


  • Subject: Re: NSTextAttachmentCell as rollover in NSTextView?
  • From: Douglas Davidson <email@hidden>
  • Date: Thu, 13 Apr 2006 12:51:30 -0700


On Apr 13, 2006, at 12:41 PM, Michael Link wrote:

I'm working on writing a view similar to the AddressBook details view and was considering using custom NSTextAttachmentCell's to implement some of the embedded controls. A couple years ago someone mentioned on this list that there was sample code from Douglas Davidson's WWDC 2003 presentation that showed how to accomplish some of these tricks in an NSTextView, but I haven't been able to locate any of the sample code. Does anyone know if the sample code or presentation is still available and where it could be found? Thanks.


I did present a custom text attachment demo at WWDC 2003, but it doesn't cover mouse handling; I've included the important parts below. There's some sample code showing rollover behavior in the DTS LayoutManagerDemo sample, but it doesn't involve attachments. If you have any specific questions, go ahead and ask them on the list.


Douglas Davidson


@implementation Controller

- (void)insertAttachment:(id)sender {
NSTextAttachment *attachment = [[NSTextAttachment alloc] initWithFileWrapper:nil];
MyAttachmentCell *cell = [[MyAttachmentCell alloc] init];
[attachment setAttachmentCell:cell];
[myTextView insertText:[NSAttributedString attributedStringWithAttachment:attachment]];
[cell release];
[attachment release];
}


@end

@implementation MyAttachmentCell

- (NSRect)cellFrameForTextContainer:(NSTextContainer *)textContainer proposedLineFragment:(NSRect)lineFrag glyphPosition:(NSPoint)position characterIndex:(unsigned)charIndex {
NSLog(@"line frag %@", NSStringFromRect(lineFrag));
return NSMakeRect(0, 0, lineFrag.size.width, 1);
}


- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView characterIndex:(unsigned)charIndex layoutManager:(NSLayoutManager *) layoutManager {
[[NSColor blackColor] set];
NSLog(@"cell frame %@", NSStringFromRect(cellFrame));
NSRectFill(cellFrame);
}



@end

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSTextAttachmentCell as rollover in NSTextView?
      • From: Michael Link <email@hidden>
References: 
 >NSTextAttachmentCell as rollover in NSTextView? (From: Michael Link <email@hidden>)

  • Prev by Date: NSTextAttachmentCell as rollover in NSTextView?
  • Next by Date: Re: NSTextAttachmentCell as rollover in NSTextView?
  • Previous by thread: NSTextAttachmentCell as rollover in NSTextView?
  • Next by thread: Re: NSTextAttachmentCell as rollover in NSTextView?
  • Index(es):
    • Date
    • Thread